286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A// CatalogException.java - Catalog exception
286N/A
286N/A/*
286N/A * Copyright 2001-2004 The Apache Software Foundation or its licensors,
286N/A * as applicable.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xml.internal.resolver;
286N/A
286N/A/**
286N/A * Signal Catalog exception.
286N/A *
286N/A * <p>This exception is thrown if an error occurs loading a
286N/A * catalog file.</p>
286N/A *
286N/A * @see Catalog
286N/A *
286N/A * @author Norman Walsh
286N/A * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
286N/A *
286N/A */
286N/Apublic class CatalogException extends Exception {
286N/A /** A wrapper around another exception */
286N/A public static final int WRAPPER = 1;
286N/A /** An invalid entry */
286N/A public static final int INVALID_ENTRY = 2;
286N/A /** An invalid entry type */
286N/A public static final int INVALID_ENTRY_TYPE = 3;
286N/A /** Could not instantiate an XML parser */
286N/A public static final int NO_XML_PARSER = 4;
286N/A /** Unknown XML format */
286N/A public static final int UNKNOWN_FORMAT = 5;
286N/A /** Unparseable XML catalog (not XML)*/
286N/A public static final int UNPARSEABLE = 6;
286N/A /** XML but parse failed */
286N/A public static final int PARSE_FAILED = 7;
286N/A /** Text catalog ended in mid-comment */
286N/A public static final int UNENDED_COMMENT = 8;
286N/A
286N/A /**
286N/A * The embedded exception if tunnelling, or null.
286N/A */
286N/A private Exception exception = null;
286N/A private int exceptionType = 0;
286N/A
286N/A /**
286N/A * Create a new CatalogException.
286N/A *
286N/A * @param type The exception type
286N/A * @param message The error or warning message.
286N/A */
286N/A public CatalogException (int type, String message) {
286N/A super(message);
286N/A this.exceptionType = type;
286N/A this.exception = null;
286N/A }
286N/A
286N/A /**
286N/A * Create a new CatalogException.
286N/A *
286N/A * @param type The exception type
286N/A */
286N/A public CatalogException (int type) {
286N/A super("Catalog Exception " + type);
286N/A this.exceptionType = type;
286N/A this.exception = null;
286N/A }
286N/A
286N/A /**
286N/A * Create a new CatalogException wrapping an existing exception.
286N/A *
286N/A * <p>The existing exception will be embedded in the new
286N/A * one, and its message will become the default message for
286N/A * the CatalogException.</p>
286N/A *
286N/A * @param e The exception to be wrapped in a CatalogException.
286N/A */
286N/A public CatalogException (Exception e) {
286N/A super();
286N/A this.exceptionType = WRAPPER;
286N/A this.exception = e;
286N/A }
286N/A
286N/A /**
286N/A * Create a new CatalogException from an existing exception.
286N/A *
286N/A * <p>The existing exception will be embedded in the new
286N/A * one, but the new exception will have its own message.</p>
286N/A *
286N/A * @param message The detail message.
286N/A * @param e The exception to be wrapped in a CatalogException.
286N/A */
286N/A public CatalogException (String message, Exception e) {
286N/A super(message);
286N/A this.exceptionType = WRAPPER;
286N/A this.exception = e;
286N/A }
286N/A
286N/A /**
286N/A * Return a detail message for this exception.
286N/A *
286N/A * <p>If there is an embedded exception, and if the CatalogException
286N/A * has no detail message of its own, this method will return
286N/A * the detail message from the embedded exception.</p>
286N/A *
286N/A * @return The error or warning message.
286N/A */
286N/A public String getMessage ()
286N/A {
286N/A String message = super.getMessage();
286N/A
286N/A if (message == null && exception != null) {
286N/A return exception.getMessage();
286N/A } else {
286N/A return message;
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * Return the embedded exception, if any.
286N/A *
286N/A * @return The embedded exception, or null if there is none.
286N/A */
286N/A public Exception getException ()
286N/A {
286N/A return exception;
286N/A }
286N/A
286N/A /**
286N/A * Return the exception type
286N/A *
286N/A * @return The exception type
286N/A */
286N/A public int getExceptionType ()
286N/A {
286N/A return exceptionType;
286N/A }
286N/A
286N/A /**
286N/A * Override toString to pick up any embedded exception.
286N/A *
286N/A * @return A string representation of this exception.
286N/A */
286N/A public String toString ()
286N/A {
286N/A if (exception != null) {
286N/A return exception.toString();
286N/A } else {
286N/A return super.toString();
286N/A }
286N/A }
286N/A}