Re: [Sisc-users] Re: java stack trace
| Newsgroups | gmane.comp.java.sisc.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jul 01, 2003 at 11:43:04PM +0100, Matthias Radestock wrote: > [email protected] wrote: > >On Tue, Jul 01, 2003 at 04:56:05PM -0400, Narang wrote: > > > >>can you please provide an example. Thanks. > > > > > >Sorry. > > > >(import s2j) > >(import generic-procedures) > >(define-java-class <java.lang.Exception>) > >(define-generic-java-method print-stack-trace) > > > >(define (print-java-stack-trace erec) > > (cond [(assq 'java-exception erec) => > > (lambda (je) > > (print-stack-trace (cdr je)))] > > [else (error 'print-java-stack-trace > > "No Java exception associated.")])) > > > > There is no need for s2j. > > Stack traces for exceptions thrown from s2j can be printed using > print-exception. They are also printed automatically by the REPL (just > like the Scheme exception stack trace) if the stack-trace-on-error > parameter is #t. > > Stack traces for the nested Java exceptions of ordinary primitives can > be displayed as follows: > > #;> (java/class 'foo) > Error in java/class: class foo not found > ?:?:?: <indeterminate call> > file:repl.scm:79:34: <from call to eval> > file:repl.scm:104:20: <indeterminate call> > file:repl.scm:92:9: <indeterminate call> > #;> (display-java-stack-trace (cdr (assq 'java-exception > (get-last-exception)))) > java.lang.RuntimeException: class foo not found > at sisc.modules.s2j.Reflection.doApply(Reflection.java:281) > at sisc.nativefun.NativeProcedure.apply(NativeProcedure.java:26) > at sisc.exprs.AppEval.eval(AppEval.java:29) > at sisc.interpreter.Interpreter.next(Interpreter.java:128) > at sisc.exprs.AppExp.eval(AppExp.java:33) > at sisc.interpreter.Interpreter.interpret(Interpreter.java:112) > at sisc.interpreter.Interpreter.interpret(Interpreter.java:101) > at sisc.interpreter.Interpreter.eval(Interpreter.java:244) > at sisc.data.SchemeThread.run(SchemeThread.java:62) > at java.lang.Thread.run(Thread.java:536) > #;> > > > You shouldn't need this in normal use. I believe the example he was referring to fit into neither category. In cases where a RuntimeException is thrown from a Primitive, we did not record the Java exception previously. Recording it will be necessary for the IO Conditions SRFI for example. Scott
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/Amnyr9IW4v3mHtQRAlIWAJwNWuY/K0xXJTwH48ujWTZpUv64/QCfWsgP My8F7mBZC+GATBQcHHvMEGw= =63xo -----END PGP SIGNATURE-----