agj_chile
2020-5-15 16:00:40

@agj_chile has joined the channel


badkins
2020-5-15 20:00:39

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.


badkins
2020-5-15 20:00:51

e.g. exn:fail


badkins
2020-5-15 20:04:59

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.


samth
2020-5-15 20:05:57

@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>)


badkins
2020-5-15 20:07:19

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.


samth
2020-5-15 20:09:08

There isn’t really much else there in general; just the message and the stack trace


badkins
2020-5-15 20:09:44

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.


samth
2020-5-15 20:10:35

Maybe adding a command to xrepl like ,bt that produced the exception value


badkins
2020-5-15 20:11:13

I bet there’s a way to have the REPL execute code on startup, right? :slightly_smiling_face:


samth
2020-5-15 20:12:12

yes, what I mean is that I don’t think a declarative config would make sense — you’d want a program


samth
2020-5-15 20:12:21

and you can add that to ~/.racketrc


badkins
2020-5-15 20:12:28

great - thanks again Sam