groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: Is it possible to implement in the language an `else` block in exception handling?
Date Mon, 28 Sep 2015 05:55:25 GMT
Am 28.09.2015 05:20, schrieb Edinson E. PadrĂ³n Urdaneta:
> |This way we could write the following list of 'constructs':
> |
> |
> - try-catch-else-finally|
> |- try-catch|-else
> |- try-else-finally|
> ||- try-else (I'm not so sure about this one, it could be in conflict
> with java(?))
> |
> |
> This will improves the readability of exception handling in some
> situations. What do you guys think about it?

what types of exceptions would be catched in the else block? if it is 
Exception and subclasses, we have already something. Example:

try  {
   foo()
} catch (SomeException se) {
// handle SomeException
} catch (e) {
// handle exception which is not a SomeException
}

going to Throwable or Error can be problematic. And the short version of 
the catch here also easily allows to still handle the exception itself. 
Does this do what you want?

bye blackdrag

-- 
Jochen "blackdrag" Theodorou
blog: http://blackdragsview.blogspot.com/


Mime
View raw message