[Rd] calling browser on error

Vadim Ogranovich vogranovich at jumptrading.com
Fri Oct 15 20:27:56 CEST 2010

Dear R-developers,

I am trying to figure out a way to call browser() when an error occur, and naturally I want the browser() to be called in the environment of the error.

I tried something simple in vain:

> f <- function() { x <- 1; stop('ok') }
> tryCatch(f(), error=browser())
Called from: tryCatch(f(), error = browser())
## if browser() was called in the local environment of f then 'x' would be set, but it's not
Browse[1]> x
Error: object 'x' not found
Browse[1]> Q

Is there a way to make it work? What do people do to 'set an on-error breakpoint'?


Note: This email is for the confidential use of the named addressee(s) only and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you are hereby notified that any review, dissemination or copying of this email is strictly prohibited, and to please notify the sender immediately and destroy this email and any attachments.  Email transmission cannot be guaranteed to be secure or error-free.  Jump Trading, therefore, does not make any guarantees as to the completeness or accuracy of this email or any attachments.  This email is for informational purposes only and does not constitute a recommendation, offer, request or solicitation of any kind to buy, sell, subscribe, redeem or perform any type of transaction of a financial product.

More information about the R-devel mailing list