当前位置:K88软件开发文章中心编程语言JavaGroovy → 文章内容

Groovy 异常处理

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-15 15:49:49

println(ex.toString()); println(ex.getMessage()); println(ex.getStackTrace()); } catch(Exception ex) { println("Catching the exception"); }finally { println("The final block"); } println("Let's move on after the exception"); } }当我们运行上面的程序,我们将得到以下结果 -java.lang.ArrayIndexOutOfBoundsException: 5 5 [org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayPutAtMetaMethod$MyPojoMetaMet hodSite.call(IntegerArrayPutAtMetaMethod.java:75), org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) ,org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) ,org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) ,Example.main(Sample:8), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method),sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57),sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ,java.lang.reflect.Method.invoke(Method.java:606),org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93),groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325),groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1443),org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:893),groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:287),groovy.lang.GroovyShell.run(GroovyShell.java:524),groovy.lang.GroovyShell.run(GroovyShell.java:513),groovy.ui.GroovyMain.processOnce(GroovyMain.java:652),groovy.ui.GroovyMain.run(GroovyMain.java:384),groovy.ui.GroovyMain.process(GroovyMain.java:370),groovy.ui.GroovyMain.processArgs(GroovyMain.java:129),groovy.ui.GroovyMain.main(GroovyMain.java:109),sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method),sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57),sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ,java.lang.reflect.Method.invoke(Method.java:606),org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109),org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131),sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method),sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57),sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ,java.lang.reflect.Method.invoke(Method.java:606),com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)] The final block Let's move on after the exception

上一页  [1] [2] 


Groovy 异常处理