[Hawkular-dev] [metrics] Consistent error replies from REST API

Heiko W.Rupp hrupp at redhat.com
Fri Mar 6 04:57:33 EST 2015


We should all over the place

a) specifc exceptions for some of the more common cases
like StuffNotFoundException(message)

b) add Exception mappers that deal with mapping that exception content to some sensible output depending on requested media type.

We have done that in RHQ, which could for the start be copied 1:1.
See

https://github.com/rhq-project/rhq/blob/master/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/CustomExceptionMapper.java
and
https://github.com/rhq-project/rhq/blob/master/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ParameterMissingException.java
and
https://github.com/rhq-project/rhq/blob/master/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/StuffNotFoundException.java




> Am 05.03.2015 um 18:32 schrieb Thomas Segismont <tsegismo at redhat.com>:
> 
> Hi,
> 
> There's a growing portion of application code in the metrics REST API 
> which returns errors (with whichever HTTP status) in the following form:
> 
> ====
> {"errorMsg": "blah"}
> ====
> 
> Whether this format is nice or suitable is not the purpose of this 
> message. I just want to draw your attention to the fact that being 
> consistent regarding error reporting is important.
> 
> In this regard, I've added a new ExceptionMapper for 
> org.jboss.resteasy.spi.ReaderException[2] instances. So now, not only 
> application errors conform to the format above, but also errors coming 
> from payload parsing.
> 
> Regards,
> Thomas
> 
> [1] 
> http://docs.jboss.org/resteasy/docs/3.0.9.Final/userguide/html_single/#builtinException
> _______________________________________________
> hawkular-dev mailing list
> hawkular-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hawkular-dev

-- 
Reg. Adresse: Red Hat GmbH, Technopark II, Haus C, 
Werner-von-Siemens-Ring 14, D-85630 Grasbrunn
Handelsregister: Amtsgericht München HRB 153243
Geschäftsführer: Charles Cachera, Michael Cunningham, Paul Hickey, Charlie Peters




More information about the hawkular-dev mailing list