errortrace-pkg
1 Quick Instructions
2 API
setup
3 Example
8.12

errortrace-pkg🔗ℹ

Sorawee Porncharoenwase <sorawee.pwase@gmail.com>

 (require errortrace-pkg) package: errortrace-pkg

This package allows users to use errortrace on installed packages.

1 Quick Instructions🔗ℹ

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

procedure

(setup pkgs)  void?

  pkgs : (listof string?)
This function installs a handler so that errortrace instruments code for non-packages and only packages specified in pkgs.

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.

Instead, errortrace-pkg could be used to help with this kind of situation. Running
  racket -l errortrace -l errortrace-pkg -t test.rkt -- --errortrace-pkg datalog
results in:

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