001: /*
002: * Copyright (C) 2004 TiongHiang Lee
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: * Email: thlee@onemindsoft.org
019: */
020:
021: package org.onemind.jxp;
022:
023: import org.onemind.jxp.parser.SimpleNode;
024:
025: /**
026: * A processing exception
027: * @author TiongHiang Lee (thlee@onemindsoft.org)
028: *
029: */
030: public class ProcessingException extends Exception {
031:
032: /** the page that has problem * */
033: private JxpPage _page;
034:
035: /** the error node * */
036: private SimpleNode _errNode;
037:
038: /**
039: * Constructor
040: * @param page the page that cause the exception
041: * @param message the message
042: */
043: public ProcessingException(JxpPage page, String message) {
044: super (message);
045: _page = page;
046: }
047:
048: /**
049: * Constructor
050: * @param page the page that cause the exception
051: * @param message the message
052: * @param cause the cause
053: */
054: public ProcessingException(JxpPage page, String message,
055: Throwable cause) {
056: super (message, cause);
057: _page = page;
058: }
059:
060: /**
061: * Constructor
062: * @param page the page that cause the exception
063: * @param message the message
064: * @param cause the cause
065: * @param errNode the error node
066: */
067: public ProcessingException(JxpPage page, String message,
068: Throwable cause, SimpleNode errNode) {
069: super (message, cause);
070: _errNode = errNode;
071: _page = page;
072: }
073:
074: /**
075: * Constructor
076: * @param page the page that cause the exception
077: * @param message the message
078: * @param errNode the error node
079: */
080: public ProcessingException(JxpPage page, String message,
081: SimpleNode errNode) {
082: super (message);
083: _errNode = errNode;
084: _page = page;
085: }
086:
087: /**
088: * Constructor
089: * @param page the page that cause the exception
090: * @param cause the cause
091: * @param errNode the error node
092: */
093: public ProcessingException(JxpPage page, Throwable cause,
094: SimpleNode errNode) {
095: super (cause);
096: _errNode = errNode;
097: _page = page;
098: }
099:
100: /**
101: * Get the error node
102: * @return the node
103: */
104: public final SimpleNode getErrNode() {
105: return _errNode;
106: }
107:
108: /**
109: * Set the error node
110: * @param node the node
111: */
112: public final void setErrNode(SimpleNode node) {
113: _errNode = node;
114: }
115:
116: /**
117: * {@inheritDoc}
118: */
119: public final String getMessage() {
120: if (_errNode != null) {
121: StringBuffer sb = new StringBuffer();
122: if (getCause() != null) {
123: sb.append(getCause().getMessage());
124: } else {
125: sb.append(super .getMessage());
126: }
127: sb.append(" at " + _page.getName());
128: sb.append(" line " + _errNode.getLine());
129: sb.append(", column " + _errNode.getCol());
130: return sb.toString();
131: } else {
132: return super.getMessage();
133: }
134: }
135: }
|