[openstack-dev] [wsme] WSME/Pecan serializing Exceptions

Sylvain Bauza sylvain.bauza at gmail.com
Tue Feb 4 16:21:18 UTC 2014


hi Doug,


2014-02-04 Doug Hellmann <doug.hellmann at dreamhost.com>:

>
>
>
> On Tue, Feb 4, 2014 at 9:43 AM, Sylvain Bauza <sylvain.bauza at gmail.com>wrote:
>
>>
>>
> If the exception has a "code" attribute, it is set as the status code for
> the response. Otherwise, the status is set to 500 as a default. There are a
> set of exception classes in wsme.exc that set the status code and can be
> used as base classes for exceptions in the API controllers.
>
>
The thing is that we raised our own Exceptions in our previous API which
were properly rendered. Here, even when raising an exception from the
controller, WSME "eats" the exception, takes the code and renders only the
exc_info without the whole text.



> The typical way to handle this is to catch underlying exceptions for
> situations that are known to be likely (no such object, permission issue,
> etc.) and re-raise an exception with a valid status code and useful
> message. Unexpected exceptions then result in a 500.
>
>
Well, that means we have to duplicate for each RPC call the try:except:
statement while we previously implemented in Flask some way to catch any
Exception and render appropriately [2].

AIUI, I will have to do some hackativity for managing the exc and properly
render it on the middleware side...

Thanks for the reply, Doug, really appreciated,
-Sylvain

[2] :
https://github.com/stackforge/climate/blob/master/climate/api/utils.py#L78





> Doug
>
>
>
>>
>> -Sylvain
>>
>> [1] https://github.com/stackforge/wsme/blob/master/wsmeext/pecan.py#L90
>>
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140204/acfc19a2/attachment.html>


More information about the OpenStack-dev mailing list