001: /*
002: * $Id: MarkupException.java 459003 2006-02-05 17:23:43Z jdonnerstag $
003: * $Revision: 459003 $ $Date: 2006-02-05 18:23:43 +0100 (Sun, 05 Feb 2006) $
004: *
005: * ==============================================================================
006: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007: * use this file except in compliance with the License. You may obtain a copy of
008: * the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015: * License for the specific language governing permissions and limitations under
016: * the License.
017: */
018: package wicket.markup;
019:
020: import wicket.WicketRuntimeException;
021: import wicket.util.resource.IResourceStream;
022:
023: /**
024: * Runtime exception that is thrown when markup parsing fails.
025: *
026: * @author Jonathan Locke
027: */
028: public final class MarkupException extends WicketRuntimeException {
029: private static final long serialVersionUID = 1L;
030:
031: /** The markup stream that was being parsed when the exception was thrown */
032: private MarkupStream markupStream;
033:
034: /**
035: * Constructor
036: *
037: * @param message
038: * The problem description
039: */
040: public MarkupException(final String message) {
041: super (message);
042: markupStream = null;
043: }
044:
045: /**
046: * @param resource
047: * The markup resource where this exception occurred
048: * @param message
049: * The message
050: */
051: public MarkupException(final IResourceStream resource,
052: final String message) {
053: super (resource.toString() + ": " + message);
054: markupStream = null;
055: }
056:
057: /**
058: * @param resource
059: * The markup where this exception occurred
060: * @param message
061: * The message
062: * @param cause
063: * The causing exception
064: */
065: public MarkupException(final IResourceStream resource,
066: final String message, final Throwable cause) {
067: super (resource.toString() + ": " + message, cause);
068: markupStream = null;
069: }
070:
071: /**
072: * @param markupStream
073: * The markup stream where this exception occurred
074: * @param message
075: * The message
076: */
077: public MarkupException(final MarkupStream markupStream,
078: final String message) {
079: super (message + "\n" + markupStream.toString());
080: this .markupStream = markupStream;
081: }
082:
083: /**
084: * @param markupStream
085: * The markup stream where this exception occurred
086: * @param message
087: * The message
088: * @param cause
089: * The causing exception
090: */
091: public MarkupException(final MarkupStream markupStream,
092: final String message, final Throwable cause) {
093: super (message + "\n" + markupStream.toString(), cause);
094: this .markupStream = markupStream;
095: }
096:
097: /**
098: * @return Returns the MarkupStream.
099: */
100: public MarkupStream getMarkupStream() {
101: return markupStream;
102: }
103:
104: /**
105: * Set the markup stream which caused the exception
106: * @param markupStream
107: */
108: public void setMarkupStream(final MarkupStream markupStream) {
109: this.markupStream = markupStream;
110: }
111: }
|