use of org.apache.qpid.protonj2.client.exceptions.ClientSessionRemotelyClosedException in project qpid-protonj2 by apache.
the class ClientExceptionSupport method convertToSessionClosedException.
/**
* Given an ErrorCondition instance create a new Exception that best matches
* the error type that indicates the session creation failed for some reason.
*
* @param errorCondition
* The ErrorCondition returned from the remote peer.
*
* @return a new Exception instance that best matches the ErrorCondition value.
*/
public static ClientSessionRemotelyClosedException convertToSessionClosedException(ErrorCondition errorCondition) {
final ClientSessionRemotelyClosedException remoteError;
if (errorCondition != null && errorCondition.getCondition() != null) {
String message = extractErrorMessage(errorCondition);
if (message == null) {
message = "Session remotely closed without explanation";
}
remoteError = new ClientSessionRemotelyClosedException(message, new ClientErrorCondition(errorCondition));
} else {
remoteError = new ClientSessionRemotelyClosedException("Session remotely closed without explanation");
}
return remoteError;
}
Aggregations