errortrace-pkg
(require errortrace-pkg) | package: errortrace-pkg |
This package allows users to use errortrace on installed packages.
1 Quick Instructions
If your program has a module file ‹prog›, run it with
racket -l errortrace -l errortrace-pkg -t ‹prog› -- [--errortrace-pkg ‹pkg›] ... ‹rest-arg› ...
- If your program is a non-module top-level sequence of definitions and expressions, add:to the beginning of your program, where pkgs is a list of package names (see setup for details). Then, run it normally with:
racket -f ‹prog›
Alternatively, run the program with
racket -l racket/init -l errortrace -l errortrace-pkg -f ‹prog› -- [--errortrace-pkg ‹pkg›] ... ‹rest-arg› ...
- If you have no main program and you want to use Racket interactively, include the -i flag before -l:racket -i -l errortrace -l errortrace-pkg -- [--errortrace-pkg ‹pkg›] ... ‹rest-arg› ...
After starting errortrace-pkg 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-pkg 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.
Unlike errortrace, there is no need to remove the "compiled" directory before running programs. All non-package program will be instrumented.
2 API
(require errortrace-pkg/lib) | package: errortrace-pkg |
Only call this function when the running program is not a module. See Quick Instructions for the instructions.
3 Example
Following program "test.rkt" is a reduced version of https://gist.github.com/anentropic/976121f288e7f0a2e91e8de082f44096
#lang racket (require datalog) (define (make-echo-hash) (impersonate-hash (make-hash) (lambda (hash key) (values key (lambda (hash key val) (printf "~a: ~a\n" key val)))) (lambda (hash key val) (values key val)) (lambda (hash key) key) (lambda (hash key) key) (lambda (hash) (hash-clear! hash)) (lambda (hash key) key))) (define family (make-echo-hash)) (datalog family (! (:- (nephew X Y) (nibling X Y) (male X)))) (datalog family (? (nephew X paul)))
Running
racket test.rkt
results in the following error:
for-each: contract violation |
expected: list? |
given: #<void> |
To debug the error, one might attempt to use
racket -l errortrace -t test.rkt
However, the result is not helpful:
for-each: contract violation |
expected: list? |
given: #<void> |
errortrace...: |
/path/to/test.rkt:31:0: (datalog family (? (nephew X paul))) |
The problem in this case is that the datalog module is not instrumented by errortrace, so errortrace could not provide any useful information to us.
for-each: contract violation |
expected: list? |
given: #<void> |
errortrace...: |
/path/to/pkgs/datalog/runtime.rkt:103:4: (for-each <elided> (get thy (subgoal-question sg))) |
/path/to/pkgs/datalog/eval.rkt:37:5: (prove (current-theory) (query-question s)) |
/path/to/pkgs/datalog/stx.rkt:55:10: (idY21 lifted/18 <elided>) |
/path/to/pkgs/datalog/stx.rkt:53:9: (->substitutions <elided> <elided>) |
In particular, it shows that (get thy (subgoal-question sg)) evaluates to (void).