View Javadoc

1   package org.andromda.core.anttasks;
2   
3   import java.lang.reflect.Method;
4   
5   
6   /***
7    * <p>This exception is thrown when something goes wrong during the
8    * procesing of a Velocity template script.</p>
9    * 
10   * @author Matthias Bohlen
11   */
12  public final class ClassTemplateProcessingException
13      extends Exception
14  {
15  
16      /***
17       * Constructor for ClassTemplateProcessingException.
18       */
19      public ClassTemplateProcessingException() {
20          super();
21      }
22  
23      /***
24       * Constructor for ClassTemplateProcessingException.
25       * @param message
26       */
27      public ClassTemplateProcessingException(String message) {
28          super(message);
29      }
30  
31      /***
32       * Constructor for ClassTemplateProcessingException.
33       * @param message
34       * @param cause
35       */
36      public ClassTemplateProcessingException(String message, Throwable cause) {
37          super(message + ": " + cause.getMessage());
38          myInitCause(cause);
39      }
40  
41      private void myInitCause(Throwable cause) {
42          if (null != initCauseMethod) {
43              try {
44                  initCauseMethod.invoke(this, new Object[] { cause });
45              } catch (Exception ex) {
46                  // We're probably running in a pre-1.4 JRE
47                  // Ignore the exception
48              }
49          }
50      }
51  
52      private static Method initCauseMethod = null;
53  
54      static {
55          try {
56              Class myClass = ClassTemplateProcessingException.class;
57              initCauseMethod = myClass.getMethod("initCause", new Class[] { Throwable.class });
58          } catch (Exception ex) {
59              // We're probably running in a pre-1.4 JRE
60              // Ignore the exception
61          }
62      }
63  }