View Javadoc

1   /*
2    * $Id: ConnectorException.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.transport;
12  
13  import org.mule.api.MuleException;
14  import org.mule.config.i18n.CoreMessages;
15  import org.mule.config.i18n.Message;
16  
17  /**
18   * <code>ConnectorException</code> Is thrown in the context of a Connector,
19   * usually some sort of transport level error where the connection has failed. This
20   * exception maintains a reference to the connector.
21   * 
22   * @see Connector
23   */
24  public class ConnectorException extends MuleException
25  {
26      /**
27       * Serial version
28       */
29      private static final long serialVersionUID = 4729481487016346035L;
30  
31      /**
32       * The connector relevant to this exception
33       */
34      private transient Connector connector;
35  
36      /**
37       * @param message the exception message
38       * @param connector where the exception occurred or is being thrown
39       */
40      public ConnectorException(Message message, Connector connector)
41      {
42          super(generateMessage(message, connector));
43          this.connector = connector;
44      }
45  
46      /**
47       * @param message the exception message
48       * @param connector where the exception occurred or is being thrown
49       * @param cause the exception that cause this exception to be thrown
50       */
51      public ConnectorException(Message message, Connector connector, Throwable cause)
52      {
53          super(generateMessage(message, connector), cause);
54          this.connector = connector;
55      }
56  
57      private static Message generateMessage(Message message, Connector connector)
58      {
59          Message m = CoreMessages.connectorCausedError(connector);
60          if (message != null)
61          {
62              message.setNextMessage(m);
63          }
64          return message;
65      }
66  
67      public Connector getConnector()
68      {
69          return connector;
70      }
71  }