mbutterick/pollen

Stack trace in error message does not show locations in .pm files

bluebear94 opened this issue · 2 comments

For example, you might get the following error message:

nc: arity mismatch;
 the expected number of arguments does not match the given number
  expected: 1
  given: 2

  context...:
   body of (submod "/home/kozet/ncv9/src/grammar/nouns.html.pm" pollen-module)
   /home/kozet/.local/share/racket/8.1/pkgs/pollen/pollen/private/cache-utils.rkt:67:0: path->hash
   /home/kozet/.local/share/racket/8.1/pkgs/pollen/pollen/private/cache-utils.rkt:124:2: generate-dest-file
   /usr/share/racket/collects/file/cache.rkt:63:2: fetch-and-continue
   /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:555:3
   /home/kozet/.local/share/racket/8.1/pkgs/pollen/pollen/private/cache-utils.rkt:114:0: cache-ref!
   /usr/share/racket/collects/racket/private/more-scheme.rkt:377:2: hash-ref!
   /home/kozet/.local/share/racket/8.1/pkgs/pollen/pollen/cache.rkt:39:4: cached-require-base
   body of 'g43165
   /home/kozet/.local/share/racket/8.1/pkgs/pollen/pollen/render.rkt:386:0: render-markup-or-markdown-source
   /home/kozet/.local/share/racket/8.1/pkgs/pollen/pollen/render.rkt:312:25: render
   /home/kozet/.local/share/racket/8.1/pkgs/pollen/pollen/private/cache-utils.rkt:124:2: generate-dest-file
   /usr/share/racket/collects/file/cache.rkt:63:2: fetch-and-continue
   /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:555:3
   /home/kozet/.local/share/racket/8.1/pkgs/pollen/pollen/private/cache-utils.rkt:114:0: cache-ref!
   /usr/share/racket/collects/racket/private/more-scheme.rkt:377:2: hash-ref!
   ...
pollen: /error.css 

where you don't get any information on where in nouns.html.pm the error is.

AFAIK that’s just the way errors are reported when they arise from modules that are synthesized at compile time. For instance, this source:

#lang scribble/manual

@(error 'boom)

Produces this error:

error: boom
  context...:
   body of "path/to/foo.scrbl"

FWIW, errortrace can work with Pollen programs. Given:

#lang pollen

Hello ◊(/ 1 0) world

Running racket test.html.pm results in:

/: division by zero
  context...:
   body of (submod "/Users/sorawee/test.html.pm" pollen-module)

But running racket -l errortrace -t test.html.pm results in:

/: division by zero
  errortrace...:
   /Users/sorawee/test.html.pm:3:7: (/ 1 0)
  context...:
   body of (submod "/Users/sorawee/test.html.pm" pollen-module)