KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > xml > ConfigurationException


1 package jfun.yan.xml;
2
3 /**
4  * Represents any error happened during the interpretation of
5  * the xml config file.
6  * <p>
7  * @author Ben Yu
8  * Nov 10, 2005 12:25:54 AM
9  */

10 public class ConfigurationException extends RuntimeException JavaDoc{
11   private final Location loc;
12   /**
13    * Creates a ConfigurationException object.
14    * @param msg the error message.
15    * @param cause the causing exception.
16    * @param loc the location within the config file.
17    */

18   public ConfigurationException(String JavaDoc msg, Throwable JavaDoc cause, Location loc) {
19     super(toStr(loc)+msg, cause);
20     this.loc = loc;
21   }
22   /**
23    * Creates a ConfigurationException object.
24    * @param msg the error message.
25    * @param loc the location within the config file.
26    */

27   public ConfigurationException(String JavaDoc msg, Location loc) {
28     super(toStr(loc)+msg);
29     this.loc = loc;
30   }
31
32   /**
33    * Creates a ConfigurationException object.
34    * @param cause the causing exception.
35    * @param loc the location within the config file.
36    */

37   public ConfigurationException(Throwable JavaDoc cause, Location loc) {
38     super(toStr(loc)+cause.getMessage(), cause);
39     this.loc = loc;
40   }
41
42   /**
43    * Get the location within the config file where the error happens.
44    */

45   public Location getLocation() {
46     return loc;
47   }
48   private static String JavaDoc toStr(Location loc){
49     if(loc==null) return "";
50     return loc.getModule() + " line " + loc.getLineNo() + ": ";
51   }
52 }
53
Popular Tags