View Javadoc

1   package org.andromda.core.common;
2   
3   import java.lang.reflect.Method;
4   
5   /***
6    * An exception thrown whenever an error is encountered while parsing meta data.
7    * 
8    * @author    <A HREF="http://www.amowers.com">Anthony Mowers</A>
9    */
10  public final class RepositoryReadException extends Exception
11  {
12  
13  	/***
14  	 *  Constructor for the MetaDataReadException object
15  	 */
16  	public RepositoryReadException()
17  	{
18  		super();
19  	}
20  
21  	/***
22  	 *  Constructor for the MetaDataReadException object
23  	 *
24  	 *@param  message  describes cause of the exception
25  	 */
26  	public RepositoryReadException(String message)
27  	{
28  		super(message);
29  	}
30  
31  	/***
32  	 *  Constructor for the MetaDataReadException object
33  	 *
34  	 *@param  message  describes cause of the exception
35  	 *@param  cause  original exception that caused this exception
36  	 */
37  	public RepositoryReadException(String message, Throwable cause)
38  	{
39  		super(message + ": " + cause.getMessage());
40  		myInitCause(cause);
41  	}
42  
43  	/***
44  	 *  Description of the Method
45  	 *
46  	 *@param  cause  chained this exception to the original cause
47  	 */
48  	private void myInitCause(Throwable cause)
49  	{
50  		if (null != initCauseMethod)
51  		{
52  			try
53  			{
54  				initCauseMethod.invoke(this, new Object[] { cause });
55  			}
56  			catch (Exception ex)
57  			{
58  				// We're probably running in a pre-1.4 JRE
59  				// Ignore the exception
60  			}
61  		}
62  	}
63  
64  	private static Method initCauseMethod = null;
65  
66  	static {
67  		try
68  		{
69  			Class myClass = RepositoryReadException.class;
70  			initCauseMethod =
71  				myClass.getMethod("initCause", new Class[] { Throwable.class });
72  		}
73  		catch (Exception ex)
74  		{
75  			// We're probably running in a pre-1.4 JRE
76  			// Ignore the exception
77  		}
78  	}
79  }