You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the idea with the Rest API Class and the Service Impl is very good and i like it. My Problem is, that if an Impl. throws an exception, it results all the time in a HTTP Error 500.
From my point of view, there should be some default Exceptions.
An idea is to create a BaseException and some Special Exception (extends the BaseException) and containing the http error code.
Inside the Service Impl i can throw this special Exception and the function internalError handle this and change the HTTP Status.
protected void internalError(RoutingContext context, Throwable ex) {
context.response().setStatusCode(500).putHeader(HttpHeaders.CONTENT_TYPE.toString(), "application/json");
if (ex instanceof CustomBaseException) {
context.response().setStatusCode(((CustomBaseException)ex).getHttpStatusCode());
}
context.response().end(new JsonObject().put("error", ex.getMessage()).encodePrettily());
}
Or do you've an other concept to control the HTTP Status codes inside the Service Implementations ?
Thanks
Marcel
The text was updated successfully, but these errors were encountered:
Hi,
the idea with the Rest API Class and the Service Impl is very good and i like it. My Problem is, that if an Impl. throws an exception, it results all the time in a HTTP Error 500.
From my point of view, there should be some default Exceptions.
An idea is to create a BaseException and some Special Exception (extends the BaseException) and containing the http error code.
Inside the Service Impl i can throw this special Exception and the function internalError handle this and change the HTTP Status.
Or do you've an other concept to control the HTTP Status codes inside the Service Implementations ?
Thanks
Marcel
The text was updated successfully, but these errors were encountered: