Skip to content

Commit

Permalink
Let subclasses of ReplyException capture a Throwable cause (#5336)
Browse files Browse the repository at this point in the history
Closes #5335

Signed-off-by: Thomas Segismont <[email protected]>
  • Loading branch information
tsegismont committed Sep 30, 2024
1 parent e46edce commit 00fa556
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/main/java/io/vertx/core/eventbus/ReplyException.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,34 @@ public class ReplyException extends VertxException {
private final ReplyFailure failureType;
private final int failureCode;

/**
* Create a ReplyException with all attributes.
*
* @param failureType the failure type
* @param failureCode the failure code (e.g. 404)
* @param message the failure message
*/
public ReplyException(ReplyFailure failureType, int failureCode, String message, boolean noStackTrace) {
super(message, noStackTrace);
this.failureType = failureType;
this.failureCode = failureCode;
}

/**
* Create a ReplyException with all attributes, including cause.<br>
* Default {@link io.vertx.core.eventbus.impl.codecs.ReplyExceptionMessageCodec ReplyExceptionMessageCodec} doesn't support Cause!<br>
* This ctor is meant to be used for extension, together with a custom codec.
*
* @param failureType the failure type
* @param failureCode the failure code (e.g. 404)
* @param message the failure message
*/
protected ReplyException(ReplyFailure failureType, int failureCode, String message, Throwable cause, boolean noStackTrace) {
super(message, cause, noStackTrace);
this.failureType = failureType;
this.failureCode = failureCode;
}

/**
* Create a ReplyException
*
Expand All @@ -34,9 +62,7 @@ public class ReplyException extends VertxException {
* @param message the failure message
*/
public ReplyException(ReplyFailure failureType, int failureCode, String message) {
super(message);
this.failureType = failureType;
this.failureCode = failureCode;
this(failureType, failureCode, message, true);
}

/**
Expand Down Expand Up @@ -81,5 +107,4 @@ public String toString() {
String message = getMessage();
return "(" + failureType + "," + failureCode + ") " + (message != null ? message : "");
}

}

0 comments on commit 00fa556

Please sign in to comment.