1 Quick Instructions
First, throw away ".zo" versions of your program—
Then,
If your program has a module file ‹prog›, run it with
racket -l errortrace -t ‹prog›
If your program has a module file ‹prog› with a submodule ‹sub›, run it with
racket -l racket/init -l errortrace -e '(require (submod ‹prog› ‹sub›))'
- If your program is a non-module top-level sequence of definitions and expressions, you can instead add
(require errortrace)
to the beginning of the program, or start Racket with the -l option before the arguments to load your program:racket -l racket/init -l errortrace -f ‹prog› - If you have no main program and you want to use Racket interactively, include the -i flag before -l:racket -i -l errortraceThe order of the flags is important.
- To instrument the contents of a collection or package, compile it with:raco setup -j 1 --mode errortrace ...Note that because --mode doesn’t support parallel builds, -j 1 is required unless you are building packages on a single-core machine
After starting errortrace in one of these ways, when an exception occurs, the exception handler prints something like a stack trace with most recent contexts first.
The errortrace module is strange: Don’t import it into another module. Instead, the errortrace module is meant to be invoked from the top-level, so that it can install an evaluation handler, exception handler, etc.
To reuse parts of the code of errortrace, import errortrace/errortrace-lib. That library contains all of the bindings described here, but does not set the compilation handler or the error display handler.