Re: whither stack traces?
John Reppy <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
The SML'97 basis functions exnName and exnMessage are probably
being used for this purpose.
- John
On Nov 28, 2006, at 5:07 PM, Dave Herman wrote:
>> exportML is setup to map uncaught exceptions to an exit with a
>> failure status. It does not print an exception trace, since people
>> may want to run executables in situations where I/O is not possible.
>> You can print your own trace using the SMLofNJ.exnHistory function.
>
> I think I'm 95% of the way there. I can't completely reproduce the
> behavior of the REPL's backtrace facility, since I don't know what
> is used to print out information about the exception. The best I
> could muster was:
>
> fun exnDetails (Fail s) = SOME ("Fail: " ^ s)
> | exnDetails Bind = SOME "nonexhaustive binding failure"
> | exnDetails Match = SOME "nonexhaustive match failure"
> | exnDetails Div = SOME "divide by zero"
> | exnDetails Domain = SOME "domain error"
> | exnDetails Overflow = SOME "overflow"
> | exnDetails Size = SOME "size"
> | exnDetails Subscript = SOME "subscript out of bounds"
> | exnDetails _ = NONE
>
> fun printStackTrace e =
> let val ss = SMLofNJ.exnHistory e
> in
> TextIO.print ("uncaught exception " ^ (exnName e));
> (case (exnDetails e) of
> SOME s => TextIO.print (" [" ^ s ^ "]\n")
> | NONE => TextIO.print "\n");
> List.app (fn s => TextIO.print ("\t" ^ s ^ "\n")) ss
> end
>
> Since exportML doesn't print backtraces by default, it would be
> nice if SMLofNJ had a monitorExn function, analogous to
> BackTrace.monitor, for printing out backtraces exactly as at the REPL.
>
>> The Backtrace stuff provides a finer-grain trace, but at a runtime
>> performance cost.
>
> This took me quite some time to find. Is there documentation other
> than in the HISTORY file?
>
> Thanks very much!
>
> Regards,
> Dave
>
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV