DoRest - possible bug in handling error responses?

mplomer
Neuling
Neuling
Beiträge: 5
Registriert: 26. Okt 2011 01:56

DoRest - possible bug in handling error responses?

Beitrag von mplomer » 23. Mai 2012 02:34

Hi,

I ran into a problem with handling error cases and mapping them to appropriate response codes. The approach we use is to signal error conditions by raising ResponseExceptions wrapping the appropriate ErrorResponse. I assume this is correct so far?

The problem is that this approach does not work with PUT / POST / PATCH methods, since these are handled by the RESTInterfaces handleRequestResponse() method. Now, this method wraps further handler execution in a generic try / catch block that maps ANY exception to a BadRequest. In contrast, createResponse() (which handles GET / HEAD) does not guard for exceptions and lets them bubble up to JDKServer.DoRestHandler.handle(), where the ErrorResponse is properly extracted.

While the RESTInterface feels like the correct place to handle exception-to-response mapping rather than doing it in a provider-specific place like JDKServer, the latter seems to at least implement it correctly.

Then again, maybe our approach is wrong?

Cheers,
Michael

eichberg
Dozentin/Dozent
Beiträge: 448
Registriert: 25. Sep 2007 12:12
Kontaktdaten:

Re: DoRest - possible bug in handling error responses?

Beitrag von eichberg » 24. Mai 2012 16:20

The "bug" is now fixed. Just download the current release of DoRest.

Antworten

Zurück zu „Archiv“