later icon indicating copy to clipboard operation
later copied to clipboard

Request: more informative message when error occurs

Open wch opened this issue 6 years ago • 0 comments

If an error occurs when running a callback, it prints out an error message, but it can be difficult to track down the source. For example:

> later::later(identity)
later: exception occurred while executing callback: 
Evaluation error: argument "x" is missing, with no default.
> traceback()
No traceback available 

Since there's no stack trace, it can be hard to find exactly where the error occurred.

There's a similar problem if the callback is invoked via run_now(). In that case, you get a stack trace, but it only tells you that the error was triggered from execCallbacks; it doesn't show you the function where the error actually occurred.

> later::later(identity, 1)
> later::run_now(1)
Error in execCallbacks(timeoutSecs) : 
  Evaluation error: argument "x" is missing, with no default.
> traceback()
4: stop(list(message = "Evaluation error: argument \"x\" is missing, with no default.", 
       call = execCallbacks(timeoutSecs), cppstack = NULL))
3: .Call("_later_execCallbacks", PACKAGE = "later", timeoutSecs)
2: execCallbacks(timeoutSecs)
1: later::run_now(1)

Using options(error=recover) in this case only lets you go as far as execCallbacks; it won't let you get into the actual callback (in this case, identity).

wch avatar Nov 29 '17 21:11 wch