[openstack-dev] [Review] Use of exception for non-exceptional cases

Thomas Hervé therve at gmail.com
Fri Jul 12 16:07:36 UTC 2013


On Fri, Jul 12, 2013 at 5:33 PM, Monty Taylor <mordred at inaugust.com> wrote:

>
>
> On 07/11/2013 05:43 AM, Thomas Hervé wrote:
> >
> >
> > On Thu, Jul 11, 2013 at 1:49 AM, Monty Taylor <mordred at inaugust.com
> > <mailto:mordred at inaugust.com>> wrote:
> >
> >     I'd like top-post and hijack this thread for another exception
> related
> >     thing:
> >
> >     a) Anyone writing code such as:
> >
> >     try:
> >       blah()
> >     except SomeException:
> >       raise SomeOtherExceptionLeavingOutStackContextFromSomeException
> >
> >     should be mocked ruthlessly.
> >
> >
> > i don't think mocking is a good way to convey your point. Losing
> > tracebacks is not great, but having an API raising random exceptions is
> > probably worse. Can you develop?
>
> I have learned that I may have mis-read your last three words due to
> translation problems. You were not asking if I had the ability to write
> code, rather you were asking if I could elaborate.
>

Ah thanks, and sorry for the frenchism.

I think I understand your point now, which is not so much about tracebacks
but about context in the wide sense, ie enough information to understand
what's going on. I've found that we're not necessarily doing a great job at
testing the error messages: it's nice to know that FooError has been
raised, but if the message is 'Error' it leads to what you're describing,
where you need to look at the code and potentially change it to debug it. I
believe more consistent tests may help that a bit.

Cheers,

-- 
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130712/d84aa9b6/attachment.html>


More information about the OpenStack-dev mailing list