View Javadoc

1   /*
2    * $Id: TransformerException.java 12269 2008-07-10 04:19:03Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.api.transformer;
12  
13  import org.mule.api.endpoint.EndpointException;
14  import org.mule.config.i18n.Message;
15  import org.mule.transformer.TransformerUtils;
16  
17  import java.util.List;
18  
19  /**
20   * <code>TransformerException</code> is a simple exception that is thrown by
21   * transformers.
22   */
23  
24  public class TransformerException extends EndpointException
25  {
26      private static final String TRANSFORMER = "Transformer";
27      
28      /**
29       * Serial version
30       */
31      private static final long serialVersionUID = 2943589828020763649L;
32  
33      private transient Transformer transformer;
34  
35      /**
36       * @param message the exception message
37       */
38      public TransformerException(Message message, Transformer transformer)
39      {
40          super(message);
41          this.transformer = transformer;
42          addInfo(TRANSFORMER, transformer.toString());
43      }
44  
45      public TransformerException(Message message, List transformers)
46      {
47          super(message);
48          this.transformer = TransformerUtils.firstOrNull(transformers);
49          addInfo(TRANSFORMER, TransformerUtils.toString(transformers));
50      }
51  
52      /**
53       * @param message the exception message
54       * @param cause the exception that cause this exception to be thrown
55       */
56      public TransformerException(Message message, Transformer transformer, Throwable cause)
57      {
58          super(message, cause);
59          this.transformer = transformer;
60          addInfo(TRANSFORMER, transformer.toString());
61      }
62  
63      public TransformerException(Message message, List transformers, Throwable cause)
64      {
65          super(message, cause);
66          this.transformer = TransformerUtils.firstOrNull(transformers);
67          addInfo(TRANSFORMER, TransformerUtils.toString(transformers));
68      }
69  
70      public TransformerException(Transformer transformer, Throwable cause)
71      {
72          super(cause);
73          this.transformer = transformer;
74          addInfo(TRANSFORMER, (transformer == null ? "null" : transformer.toString()));
75      }
76  
77       public TransformerException(List transformers, Throwable cause)
78      {
79          super(cause);
80          this.transformer = TransformerUtils.firstOrNull(transformers);
81          addInfo(TRANSFORMER, TransformerUtils.toString(transformers));
82      }
83  
84     /**
85       * @param message the exception message
86       * @param cause the exception that cause this exception to be thrown
87       */
88      public TransformerException(Message message, Throwable cause)
89      {
90          super(message, cause);
91      }
92  
93      /**
94       * @param message the exception message
95       */
96      public TransformerException(Message message)
97      {
98          super(message);
99      }
100 
101     public Transformer getTransformer()
102     {
103         return transformer;
104     }
105 }