groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edinson E. Padrón Urdaneta <edinson.padron.urdan...@gmail.com>
Subject Re: Is it possible to implement in the language an `else` block in exception handling?
Date Thu, 01 Oct 2015 01:07:14 GMT
Well... I think this thread has rested enough. Do you like the
idea/feature/behavior? What should I do next?

On Mon, Sep 28, 2015 at 1:47 PM, Matt Quackenbush <quackfuzed@gmail.com>
wrote:

> I rather like this behavior/feature, which I'm familiar with from Python
> <http://stackoverflow.com/a/16138864>.
>
> On Mon, Sep 28, 2015 at 12:44 PM, Edinson E. Padrón Urdaneta <
> edinson.padron.urdaneta@gmail.com> wrote:
>
>> ​>What behaviour do you expect of the else block if an exception exception
>> >in the try block is thrown, which is not catched and if a finally block
>> >is present? Example:
>> >
>> >> try {
>> >>   m1() //throws MyException
>> >> } catch (SomeExceptionThatWillNotBeThrown e) {
>> >> } else {
>> >>   m2()
>> >> } finally {
>> >>   m3()
>> >> }
>> >
>> >So is this supposed to do m1();m3() then? In  other words apiece of code
>> >executed only if he try block throws no exception at all?
>> ​
>> ​Hi, Jochen. That's right, *m2()* would not be executed because the
>> exception threw wasn't catch and the normal java/groovy behavior of
>> executing *m3()* and passing the exception threw inside the try block to
>> the 'next higger context' would happen.
>>
>
>

Mime
View raw message