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