Consider this handler:
@ConsumeEvent("foo.create")
public Uni<Long> createFoo(FooCreateRequest request) {
return Uni.createFrom().item(1L)
.onItem().failWith(() -> new RuntimeException("foo error message"));
}
According to the documentation:
if a reply handler is set the failure is propagated back to the sender via an ReplyException with code ConsumeEvent.FAILURE_CODE and message Exception.toString().
Based on this, I assume that the only way to determine the status of the HTTP response in exception handler is to parse the exception message like this:
@ServerExceptionMapper(ReplyException.class)
public RestResponse<String> mapException(ReplyException e) {
Response.Status status = getStatus(e.getMessage());
return RestResponse.status(status);
}
Is there another way to do this, perhaps a way to specify a custom ReplyException.failureCode?
EDIT:
This is how my FooResource looks like:
@Inject
EventBus eventBus;
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Uni<RestResponse<Void>> createFoo(FooCreateRequest request) {
return eventBus.<Long>request("foo.create", request)
.onItem().transform(id -> RestResponse.created(...));
}
I used so-called request/reply method described in https://quarkus.io/guides/reactive-event-bus#putting-things-together-bridging-http-and-messages and from what I understood the only information about the exception that I have in FooResource and @ServerExceptionMapper method, is an exception message.