Skip to content

Commit 00fa556

Browse files
authored
Let subclasses of ReplyException capture a Throwable cause (#5336)
Closes #5335 Signed-off-by: Thomas Segismont <[email protected]>
1 parent e46edce commit 00fa556

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/main/java/io/vertx/core/eventbus/ReplyException.java

+29-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,34 @@ public class ReplyException extends VertxException {
2626
private final ReplyFailure failureType;
2727
private final int failureCode;
2828

29+
/**
30+
* Create a ReplyException with all attributes.
31+
*
32+
* @param failureType the failure type
33+
* @param failureCode the failure code (e.g. 404)
34+
* @param message the failure message
35+
*/
36+
public ReplyException(ReplyFailure failureType, int failureCode, String message, boolean noStackTrace) {
37+
super(message, noStackTrace);
38+
this.failureType = failureType;
39+
this.failureCode = failureCode;
40+
}
41+
42+
/**
43+
* Create a ReplyException with all attributes, including cause.<br>
44+
* Default {@link io.vertx.core.eventbus.impl.codecs.ReplyExceptionMessageCodec ReplyExceptionMessageCodec} doesn't support Cause!<br>
45+
* This ctor is meant to be used for extension, together with a custom codec.
46+
*
47+
* @param failureType the failure type
48+
* @param failureCode the failure code (e.g. 404)
49+
* @param message the failure message
50+
*/
51+
protected ReplyException(ReplyFailure failureType, int failureCode, String message, Throwable cause, boolean noStackTrace) {
52+
super(message, cause, noStackTrace);
53+
this.failureType = failureType;
54+
this.failureCode = failureCode;
55+
}
56+
2957
/**
3058
* Create a ReplyException
3159
*
@@ -34,9 +62,7 @@ public class ReplyException extends VertxException {
3462
* @param message the failure message
3563
*/
3664
public ReplyException(ReplyFailure failureType, int failureCode, String message) {
37-
super(message);
38-
this.failureType = failureType;
39-
this.failureCode = failureCode;
65+
this(failureType, failureCode, message, true);
4066
}
4167

4268
/**
@@ -81,5 +107,4 @@ public String toString() {
81107
String message = getMessage();
82108
return "(" + failureType + "," + failureCode + ") " + (message != null ? message : "");
83109
}
84-
85110
}

0 commit comments

Comments
 (0)