I have a related question.  I turned on error trace using the command line Robby
suggested, but it doesn't give me a trace, but rather just the call point and 
error function.  Here is an example, the trace should be f -> gg -> g -> hh -> 
h then bang, the error.   But instead Racket shows me f -> + bang,  "in context 
of h".  But which 'h' it is called many times (and in a big project many many 
times).

How do you turn on tracing?  Is there another switch, or if I go interactive is 
there a command which will give me the trace?


;; bt2-ex-fun2.rkt:
;;
  #lang racket

  (define (h x y) (+ x y))

  (define (hh x y) (h x y))

  (define (f x y)
    (gg x y)
    )

  (define (gg x y) 
    (define z 7)
    (set! z (h 5 0))
    (g (- x z) y)
    )

  (define zz 5)

  (define (g x y)
    (hh (+ x (h zz 0)) y)
    )

  (f 3 5)
  (f 3 'a)

  #| result:

  §> racket -l errortrace -t bt2-ex-fun2.rkt 
  8
  +: contract violation
    expected: number?
    given: 'a
    argument position: 2nd
    other arguments...:
     3
    errortrace...:
     /home/deep/3_doc/racket_err_mess/bt2-ex-fun2.rkt:3:16: (+ x y)
     /home/deep/3_doc/racket_err_mess/bt2-ex-fun2.rkt:24:0: (f 3 (quote a))
    context...:
     /home/deep/3_doc/racket_err_mess/bt2-ex-fun2.rkt:3:0: h
     /home/deep/3_doc/racket_err_mess/bt2-ex-fun2.rkt: [running body]

  §> 

  |#














On Thursday, November 12, 2015 at 5:19:20 PM UTC, Matthew Flatt wrote:
> At Sun, 8 Nov 2015 21:56:04 -0500, Ben Lerner wrote:
> > 
> > On 11/8/2015 9:18 PM, Nota Poin wrote:
> > >> Or if you insist on command line usage, use error trace.
> > > What's wrong with command line usage? Anyway, I was going to say this:
> > >
> > > http://docs.racket-lang.org/errortrace/using-errortrace.html
> > >
> > > That seems to enable stack traces that work.
> > >
> > Relatedly, is there a way to use this stacktrace mechanism with 
> > scribble?  That is, can I write `scribble -l errortrace <my scribble 
> > files>` or `racket -l errortrace <however you invoke scribble manually> 
> > <my scribble files>`, or would that not work out for some reason?
> 
> For errors while a document is constructed, just running
> 
>  racket -l errortrace -t <my scribble file>
> 
> would work, since a Scribble document is a Racket program.
> 
> 
> For an error that happens only during rendering, you could use
> 
>  racket -l errortrace -l scribble/run <my scribble files>
> 
> since the `scribble` program just runs the `scribble/run` module.
> 
> I'm not sure why it's `scribble/run` instead of just `scribble`, and
> maybe it's worth adding a `scribble` module as an alias. I'll think
> about that more, in case there was a reason that I've forgotten.

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

Reply via email to