01: /*
02: * $Id: ConnectorException.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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: * Serial version
27: */
28: private static final long serialVersionUID = 4729481487016346035L;
29:
30: /**
31: * The connector relevant to this exception
32: */
33: private transient Connector connector;
34:
35: /**
36: * @param message the exception message
37: * @param connector where the exception occurred or is being thrown
38: */
39: public ConnectorException(Message message, Connector connector) {
40: super (generateMessage(message, connector));
41: this .connector = connector;
42: }
43:
44: /**
45: * @param message the exception message
46: * @param connector where the exception occurred or is being thrown
47: * @param cause the exception that cause this exception to be thrown
48: */
49: public ConnectorException(Message message, Connector connector,
50: Throwable cause) {
51: super (generateMessage(message, connector), cause);
52: this .connector = connector;
53: }
54:
55: private static Message generateMessage(Message message,
56: Connector connector) {
57: Message m = CoreMessages.connectorCausedError(connector);
58: if (message != null) {
59: message.setNextMessage(m);
60: }
61: return message;
62: }
63:
64: public Connector getConnector() {
65: return connector;
66: }
67: }
|