I'm using generated VertxProxyHandler class for my service (SomeServiceVertxProxyHandler. class).
When delivering a message through an event bus (in the case that an exception occurred during the execution), I get another exception that wraps my real one and thus losing the stacktrace.
The main problem is in this code:
public void handle(Message<JsonObject> msg) {
try{
JsonObject json = msg.body();
String action = msg.headers().get("action");
if (action == null) throw new IllegalStateException("action not specified");
accessed();
switch (action) {
case "getStart": {
service.getStart((java.lang.String)json.getValue("tmsec"),
HelperUtils.createListHandler(msg));
break;
}
...
Look at the HelperUtils.createListHandler(msg) method:
public static <T> Handler<AsyncResult<List<T>>> createListHandler(Message msg) {
return res -> {
if (res.failed()) {
if (res.cause() instanceof ServiceException) {
msg.reply(res.cause());
} else {
msg.reply(new ServiceException(-1, res.cause().getMessage()));
}
If res.cause() instance of Exception (any kind of exception that may happens) and not contains message of the cause (as in case when you pass null in Objects.requireNonNull()) you will get completely another stacktrace with completely not informative message.
May be it will be better to call initCause(Throwable t) or addSuppressed(Throwable t) to not losing original exception?
I'm using generated VertxProxyHandler class for my service (
SomeServiceVertxProxyHandler. class
). When delivering a message through an event bus (in the case that an exception occurred during the execution), I get another exception that wraps my real one and thus losing the stacktrace. The main problem is in this code:Look at the
HelperUtils.createListHandler(msg)
method:If
res.cause()
instance of Exception (any kind of exception that may happens) and not contains message of the cause (as in case when you passnull
inObjects.requireNonNull()
) you will get completely another stacktrace with completely not informative message.May be it will be better to call
initCause(Throwable t)
oraddSuppressed(Throwable t)
to not losing original exception?