Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/aendvari/cerberus/component/descriptor/parser/ParserException.java


1   /*
2    * ParserException.java
3    *
4    * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5    *
6    * See the file LICENSE for terms of use.
7    *
8    */
9   
10  package com.aendvari.cerberus.component.descriptor.parser;
11  
12  /**
13   * <p>Thrown when a problem has occured while parsing a component descriptor.</p>
14   *
15   * @author  Trevor Milne
16   *
17   */
18  
19  public class ParserException extends Exception
20  {
21    /** The exception that caused this exception, may be null. */
22    protected Throwable rootCause;
23    
24    /** Stores extended information on this exception. */
25    protected StringBuffer extended;
26  
27  
28    /* Constructors */
29  
30  
31    /**
32     * Constructs a <code>ParserException</code> with no detail message.
33     *
34     */
35  
36    public ParserException()
37    {
38      super();
39  
40      rootCause = null;
41      extended = new StringBuffer();
42    }
43  
44    /**
45     * Constructs a <code>ParserException</code> with causing exception.
46     *
47     * @param    setRootCause        The exception causing this exception.
48     *
49     */
50  
51    public ParserException(Throwable setRootCause)
52    {
53      rootCause = setRootCause;
54  
55      extended = new StringBuffer();
56    }
57  
58    /**
59     * Constructs a <code>ParserException</code> with the supplied detail message.
60     *
61     * @param    setMessage          String describing error.
62     *
63     */
64  
65    public ParserException(String setMessage)
66    {
67      super(setMessage);
68  
69      extended = new StringBuffer();
70    }
71  
72    /**
73     * Constructs a <code>ParserException</code> with the supplied detail message
74     * and causing exception.
75     *
76     * @param    setMessage          String describing error.
77     * @param    setRootCause        The exception causing this exception.
78     *
79     */
80  
81    public ParserException(String message, Throwable setRootCause)
82    {
83      super(message);
84  
85      rootCause = setRootCause;
86      extended = new StringBuffer();
87    }
88  
89  
90    /* Accessors. */
91  
92  
93    /**
94     * Adds additional information to this exception.
95     *
96     * @param    message            The message to add to this exception.
97     *
98     */
99  
100   public void addMessage(String message)
101   {
102     extended.append("; ");
103     extended.append(message);
104   }
105 
106   /**
107    * Returns the exception that caused this exception, null if none.
108    *
109    */
110 
111   public Throwable getRootCause()
112   {
113     return rootCause;
114   }
115 
116   /**
117    * Returns a string representation of the exception.
118    *
119    */
120 
121   public String toString()
122   {
123     return (super.toString() + "; cause=" + rootCause + extended.toString());
124   }
125 }
126