First, throw away ".zo" versions of your program – at least for the modules or files that should be instrumented for error reporting or profiling.
If your program has a module file ‹prog›, run it with
mzscheme -l errortrace -t ‹prog›
- If you 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 MzScheme with the -l option before the arguments to load your program:mzscheme -l errortrace ...
- If you have no main program and you want to use MzScheme interactively, include the -i flag before -l:mzscheme -i -l errortrace
After starting errortrace in one of these ways, when an exception occurs, the exception handler 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.