aesteve / nubes

Annotation layer on top of Vert.x 3
Apache License 2.0
121 stars 35 forks source link

Add defaults ErrorHandler #27

Closed aesteve closed 9 years ago

aesteve commented 9 years ago

And provide a way to map them on a specific content-type

In VertxMVC :

router.failureHandler(failureHandlerRegistry)

FailureHandlerRegistry :

public void handle(RoutingContext context) {
    String contentType = context.get("best-content-type");
    PayloadMarshaller marshaller = marshallers.get(contentType);
    if (marshaller == null) {
        defaultErrorHandler.handle(context); // displays an html error page
    } else {
        marshaller.marshallError(context.failure());
    }
}

And in PayloadMarshaller interface, add a marshallError(Throwable t) method.

And add the implementation into JSONPayloadMarshaller.

Also, provide a configuration option to tell the framwork to include stacktraces in errors or not.

aesteve commented 9 years ago

implemented -> test it