@agj_chile has joined the channel
Can I configure the Racket REPL to display exceptions? When an exception occurs, I get a message, and I can use ,bt
for a stack trace, but I don’t see the actual exception object.
e.g. exn:fail
Hmm… I thought it was unique to the REPL, but that’s just the way DrRacket and/or running the program work also. I thought I’d seen exception objects, or at least their type, displayed before. Guess not.
@badkins you can change error-display-handler
. > (error-display-handler (lambda (msg exn) (println msg) (println exn)))
> (+ 'f)
"+: contract violation\n expected: number?\n given: 'f"
(exn:fail:contract "+: contract violation\n expected: number?\n given: 'f" #<continuation-mark-set>)
Awesome - thanks! Might be worth having as a config option. Sometimes, with under-documented libraries, it’s handy to poke at them and inspect the exceptions that occur to get a better idea of how to handle them.
There isn’t really much else there in general; just the message and the stack trace
I suppose it’s very subjective, but I’d prefer the normal operation to do what your error-display-handler
does. Maybe leave DrRacket alone for friendliness, but have the REPL output the exn.
Maybe adding a command to xrepl like ,bt
that produced the exception value
I bet there’s a way to have the REPL execute code on startup, right? :slightly_smiling_face:
yes, what I mean is that I don’t think a declarative config would make sense — you’d want a program
and you can add that to ~/.racketrc
great - thanks again Sam