[ 
https://issues.apache.org/jira/browse/GROOVY-5686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King closed GROOVY-5686.
-----------------------------

> Exception catching: code compiles, but exception handling confusing.
> --------------------------------------------------------------------
>
>                 Key: GROOVY-5686
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5686
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 1.8.7
>         Environment: Linux
>            Reporter: Dr Josef Karthauser
>            Priority: Major
>
> Take a look at this code. When I fail to give an exception argument in a 
> catch block that block appears to catch everything! Weird. What's going on?
> Joe
> {code}
>     @Test
>     void shouldCatchAnException_andDoes() {
>         try {
>             throw new ItemNotFoundException("")
>         } catch (ItemNotFoundException e) {
>             // ok
>             assert e
>         }
>     }
>     @Test
>     void shouldCatchAnException_wierdGroovySyntax_andDoes() {
>         try {
>             throw new ItemNotFoundException("")
>         } catch (ItemNotFoundException) {
>             // ok
>             assert true
>         }
>     }
>     @Test
>     void shouldNotCatchTheWrongException_andDoesnt() {
>         try {
>             throw new ItemNotFoundException("")
>         } catch (ValidationException e) {
>             assert false
>         } catch (Exception e) {
>             // ok
>         }
>     }
>     @Test
>     void 
> shouldNotCatchTheWrongException_withWierdGroovySyntax_butDoes_whatIsGoingOk() 
> {
>         try {
>             throw new ItemNotFoundException("")
>         } catch (ValidationException) {
>             assert false
>         } catch (Exception e) {
>             // ok
>         }
>     }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to