Arc Forumnew | comments | leaders | submitlogin
Proposal: context information in error messages
5 points by rincewind 5902 days ago | 2 comments
Every error should have a reference to the expression containing it. These expressions are attached to all error expressions before macro expansion time, so they contain the code as the user sees or writes it.

  >(when bla
  >    (do
  >       (foo)
  >       (bar)
  >       (err 'bla)))
  Error "error:bla"
  
  >(err-origin)
  (do (foo) (bar) (err 'bla))
This scheme is more general than attaching line numbers to errors, because not every expression has a line number (generated code), but everything is an expression.


1 point by shader 5794 days ago | link

Is there a way for an expression to access it's parent? We could either try and make err aware of it's surroundings, or re-read the source code and print the expression that contains the line number. Which is easier?

-----

1 point by shader 5889 days ago | link

Any idea on how this could be implemented? I think it might help if functions carried around pointers to their source code in an easy to access manner.

-----