<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 11:21 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 Doug,<br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-04 Doug Hellmann <span dir="ltr"><<a href="mailto:doug.hellmann@dreamhost.com" target="_blank">doug.hellmann@dreamhost.com</a>></span>:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small"><br></div><div class="gmail_extra">

<br><br><div class="gmail_quote"><div class="im"><div>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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br></div></blockquote><div><br></div></div>

</div><div class="im"><div><div 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 style="font-size:small"><br></div></div></div></div></div></div></blockquote><div><br></div><div>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.</div>
<div class="im">
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">

<div class="gmail_quote"><div><div style="font-size:small"></div><div 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 style="font-size:small"><br></div></div></div></div></div></blockquote><div><br></div></div><div>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].</div>

<div><br></div><div>AIUI, I will have to do some hackativity for managing the exc and properly render it on the middleware side...</div></div></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">
A decorator could convert the exceptions in a reusable way.</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 class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Thanks for the reply, Doug, really appreciated,</div><div>-Sylvain</div>
<div><br></div><div>[2] : <a href="https://github.com/stackforge/climate/blob/master/climate/api/utils.py#L78" target="_blank">https://github.com/stackforge/climate/blob/master/climate/api/utils.py#L78</a></div><div class="im">
<div><br></div><div><br></div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">

<div class="gmail_quote"><div><div style="font-size:small"></div><div style="font-size:small">Doug</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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" target="_blank">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>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">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></div><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>