<div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 4, 2014 at 9:43 AM, Sylvain Bauza <span dir="ltr"><<a href="mailto:sylvain.bauza@gmail.com" target="_blank">sylvain.bauza@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>The WSME wsexpose() decorator for Pecan serializes any Exception being raised on a controller [1]</div>
<div><br></div><div>I can understand the behaviour for security and visualization concerns, but I was wondering if it was possible to add an extra parameter to the decorator in order to explicitely raise the Exception ?</div>

<div><br></div><div>My concern is that it would be far easier to implement either a Pecan hook or an middleware app that would then capture the Exception and return it on a templatized way.</div><div><br></div><div>At the moment, I have to play with raw strings for trying to deduce which exception it was and correctly set the return values...</div>

<div><br></div><div>What do you think of it, people ? Would it be worth patching it ?</div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">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.</div>
<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">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.</div>
<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Doug</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><br></div><div>-Sylvain</div><div><br></div><div>[1] <a href="https://github.com/stackforge/wsme/blob/master/wsmeext/pecan.py#L90" target="_blank">https://github.com/stackforge/wsme/blob/master/wsmeext/pecan.py#L90</a><br>

</div></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div></div>