scala – 如何强制解释器显示完整的堆栈跟踪?
发布时间:2020-12-16 19:06:22 所属栏目:安全 来源:网络整理
导读:有没有办法强制 Scala解释器(从SBT开始)打印完整的堆栈跟踪.默认情况下,显示少于10行: scala new CacheMonitoringClientjavax.management.InstanceNotFoundException: com.bea:Name=DomainRuntimeService,Type=weblogic.management.beanservers.domainrunti
有没有办法强制
Scala解释器(从SBT开始)打印完整的堆栈跟踪.默认情况下,显示少于10行:
scala> new CacheMonitoringClient javax.management.InstanceNotFoundException: com.bea:Name=DomainRuntimeService,Type=weblogic.management.beanservers.domainrun time.DomainRuntimeServiceMBean at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195) at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:224) at javax.management.remote.rmi.RMIConnectionImpl_921_WLStub.getAttribute(Unknown Source) at weblogic.management.remote.common.RMIConnectionWrapper$11.run(ClientProviderBase.java:498) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147) at weblogic.security.Security.runAs(Security.java:61) at weblogic.management.remote.common.RMIConnectionWrapper.getAttribute(ClientProviderBas... 作为一种解决方法,我使用try {new CacheMonitoringClient} catch {case ex => ex.printStackTrace}(显式地包含我感兴趣的异常的调用),但是真的很丑陋… 解决方法
如果你只想要一件事情,请使用lastException:
scala> 1 / 0 java.lang.ArithmeticException: / by zero at .<init>(<console>:12) at .<clinit>(<console>) at RequestResult$.<init>(<console>:9) at RequestResult$.<clinit>(<console>) at RequestResult$scala_repl_result(<console>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun$apply$18.apply(Interpreter.scala:981) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun$apply$18.apply(Interpreter.scala:981) at scala.util.control.Exception$Catch.apply(Exception.scala:79) at scal... scala> lastException.printStackTrace java.lang.ArithmeticException: / by zero at line101$object$$iw$$iw$$iw$$iw$$iw$$iw$.<init>(<console>:12) at line101$object$$iw$$iw$$iw$$iw$$iw$$iw$.<clinit>(<console>) at RequestResult$line101$object$.<init>(<console>:9) at RequestResult$line101$object$.<clinit>(<console>) at RequestResult$line101$object.scala_repl_result(<console>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun$apply$18.apply(Interpreter.scala:981) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun$apply$18.apply(Interpreter.scala:981) at scala.util.control.Exception$Catch.apply(Exception.scala:79) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1.apply(Interpreter.scala:980) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1.apply(Interpreter.scala:980) at scala.util.control.Exception$Catch.apply(Exception.scala:79) at scala.tools.nsc.Interpreter$Request.loadAndRun(Interpreter.scala:979) at scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:578) at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:597) at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:575) at scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:471) at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:514) at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:361) at scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:242) at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:248) at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:558) at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:72) at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala) 或者将settings.maxPrintString设置为0,但这也会改变正常结果的打印方式. scala> settings.maxPrintString = 0 scala> 1 /0 java.lang.ArithmeticException: / by zero at .<init>(<console>:12) at .<clinit>(<console>) at RequestResult$.<init>(<console>:9) at RequestResult$.<clinit>(<console>) at RequestResult$scala_repl_result(<console>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun$apply$18.apply(Interpreter.scala:981) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun$apply$18.apply(Interpreter.scala:981) at scala.util.control.Exception$Catch.apply(Exception.scala:79) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1.apply(Interpreter.scala:980) at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1.apply(Interpreter.scala:980) at scala.util.control.Exception$Catch.apply(Exception.scala:79) at scala.tools.nsc.Interpreter$Request.loadAndRun(Interpreter.scala:979) at scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:578) at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:597) at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:575) at scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:471) at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:514) at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:361) at scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:242) at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:248) at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:558) at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:72) at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |