Stack traces are printed by the default error display handler, as opposed to being part of the exception string. So, you can convert an exception `e` to the form that prints by default by calling the error display handler directly:
(with-output-to-string (lambda () (parameterize ([current-error-port (current-output-port)]) ((error-display-handler) (exn-message e) e)))) At Mon, 3 Jul 2017 23:19:35 -0700 (PDT), reilithion wrote: > Hi, > > I have a program that uses multiple threads and may have several exceptions > happen more-or-less at once. I'd like to be able to raise them all together > and have all of them printed to stderr, including stack traces. > > I first tried just throwing them in a list and raising the list, but of > course > that doesn't come out very pretty (only one thread failed in this example): > > uncaught exception: (list (exn:fail:task-failed "I failed.\n" > #<continuation-mark-set> ...)) > > Next, I thought I'd try looping through the exceptions and using exn->string. > But it seems this function doesn't give me stack traces or any kind of source > location information. > > It occurred to me to try to use the same mechanism that the REPL does, but I > don't know anything about it, and I found the documentation on prompts and > aborts to be a bit confusing. I didn't grok how the REPL used them to pull > off > its magic trick. What's the right way to go about this? > > Thanks, > Lucas > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.