Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-4
-
None
-
xp
Description
Please see the testcase for multiple issues:
1. the catch order sensitivity, seems only the first catch clause works
2. Exceptions generated when calling a method are always wrapped in Groovy invoking exception. Users won't catch the situation by using the "original" java exception.
3. This pops up only in a loose script:
package bran.groovy
try {
1/0
} catch (Exception ex) {
println("worst")
}
The Exception was supposed to stand for the java.lang.Exception. Rather the runtime was looking for bran.package.Exception. Removing the package directive fix the problem.
---- TrycatchTest.groovy
package bran.groovy
import java.io.*
import org.codehaus.groovy.runtime.*
class TrycatchTest extends GroovyTestCase {
void testMutipleCatches() {
try
catch (InvokerInvocationException ie)
{ println("was here") }catch (FileNotFoundException e)
{ println("bad") } catch (Exception ex) { println("worst") }}
// switch the order of the catches
void testCatchesOrder() {
try { FileInputStream fis = new FileInputStream("c:\\++-~~~") println 'ok' } catch (FileNotFoundException e) { println("bad") }
catch (InvokerInvocationException ie)
{ // println("was here") }catch (Exception ex)
{ println("worst") }
}
// should probably throw the original exception
void testCatchOriginal() {
try
catch (FileNotFoundException e)
{ println("bad") }
}
void testException() {
try
catch (Exception e)
{ println("got it") }
}
}