Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ConnectorException |
|
| 1.25;1.25 |
1 | /* | |
2 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
3 | * The software in this package is published under the terms of the CPAL v1.0 | |
4 | * license, a copy of which has been included with this distribution in the | |
5 | * LICENSE.txt file. | |
6 | */ | |
7 | package org.mule.api.transport; | |
8 | ||
9 | import org.mule.api.MuleException; | |
10 | import org.mule.config.i18n.CoreMessages; | |
11 | import org.mule.config.i18n.Message; | |
12 | ||
13 | /** | |
14 | * <code>ConnectorException</code> Is thrown in the context of a Connector, | |
15 | * usually some sort of transport level error where the connection has failed. This | |
16 | * exception maintains a reference to the connector. | |
17 | * | |
18 | * @see Connector | |
19 | */ | |
20 | public class ConnectorException extends MuleException | |
21 | { | |
22 | /** | |
23 | * Serial version | |
24 | */ | |
25 | private static final long serialVersionUID = 4729481487016346035L; | |
26 | ||
27 | /** | |
28 | * The connector relevant to this exception | |
29 | */ | |
30 | private transient Connector connector; | |
31 | ||
32 | /** | |
33 | * @param message the exception message | |
34 | * @param connector where the exception occurred or is being thrown | |
35 | */ | |
36 | public ConnectorException(Message message, Connector connector) | |
37 | { | |
38 | 0 | super(generateMessage(message, connector)); |
39 | 0 | this.connector = connector; |
40 | 0 | } |
41 | ||
42 | /** | |
43 | * @param message the exception message | |
44 | * @param connector where the exception occurred or is being thrown | |
45 | * @param cause the exception that cause this exception to be thrown | |
46 | */ | |
47 | public ConnectorException(Message message, Connector connector, Throwable cause) | |
48 | { | |
49 | 0 | super(generateMessage(message, connector), cause); |
50 | 0 | this.connector = connector; |
51 | 0 | } |
52 | ||
53 | private static Message generateMessage(Message message, Connector connector) | |
54 | { | |
55 | 0 | Message m = CoreMessages.connectorCausedError(connector); |
56 | 0 | if (message != null) |
57 | { | |
58 | 0 | message.setNextMessage(m); |
59 | } | |
60 | 0 | return message; |
61 | } | |
62 | ||
63 | public Connector getConnector() | |
64 | { | |
65 | 0 | return connector; |
66 | } | |
67 | } |