Skip to content

Commit d97be88

Browse files
Make error messages of AlreadyClosedException clearer
1 parent 3396f9e commit d97be88

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/com/rabbitmq/client/AlreadyClosedException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public AlreadyClosedException(ShutdownSignalException sse)
3030
super(sse.isHardError(),
3131
sse.isInitiatedByApplication(),
3232
sse.getReason(),
33-
sse.getReference());
33+
sse.getReference(),
34+
(sse.isHardError() ? "connection" : "channel" + " is already closed due to "));
3435
}
3536
}

src/com/rabbitmq/client/ShutdownSignalException.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,25 @@ public ShutdownSignalException(boolean hardError,
5757
boolean initiatedByApplication,
5858
Method reason, Object ref)
5959
{
60-
super((initiatedByApplication
61-
? ("clean " + (hardError ? "connection" : "channel") + " shutdown")
62-
: ((hardError ? "connection" : "channel") + " error"))
63-
+ "; reason: " + reason);
60+
this(hardError, initiatedByApplication, reason, ref, "");
61+
}
62+
63+
/**
64+
* Construct a ShutdownSignalException from the arguments.
65+
* @param hardError the relevant hard error
66+
* @param initiatedByApplication if the shutdown was client-initiated
67+
* @param reason AMQP method describing the exception reason
68+
* @param ref Reference to Connection or Channel that fired the signal
69+
* @param messagePrefix prefix to add to exception message
70+
*/
71+
public ShutdownSignalException(boolean hardError,
72+
boolean initiatedByApplication,
73+
Method reason, Object ref, String messagePrefix)
74+
{
75+
super(messagePrefix + (initiatedByApplication
76+
? ("clean " + (hardError ? "connection" : "channel") + " shutdown")
77+
: ((hardError ? "connection" : "channel") + " error"))
78+
+ "; reason: " + reason);
6479
this._hardError = hardError;
6580
this._initiatedByApplication = initiatedByApplication;
6681
this._reason = reason;

0 commit comments

Comments
 (0)