search for: addcondhand

Displaying 4 results from an estimated 4 matches for "addcondhand".

Did you mean: addcondhands
2009 Apr 14
0
top level condition handlers
...ndler I set up previously. I tried modifying withCallingHandlers like this: topLevelCallingHandlers <- function(...) { handlers <- list(...) classes <- names(handlers) if (length(classes) != length(handlers)) stop("bad handler specification") .Internal(.addCondHands(classes, handlers, .GlobalEnv, .GlobalEnv, TRUE)) invisible( NULL ) } > withCallingHandlers function (expr, ...) { handlers <- list(...) classes <- names(handlers) parentenv <- parent.frame() if (length(classes) != length(handlers)) stop("bad handler...
2018 Nov 23
1
[tryExcept] New try Function
...ith <<-, but I prefer to reduce it's usage unless completely necessary. I guess that the attachment was missed in the moderation. Here it is the function: tryExcept <- function (expr, except = {}) { doTryExcept <- function(expr, parentenv) { .Internal(.addCondHands("error", list(NULL), parentenv, environment(), FALSE)) expr } parentenv <- parent.frame() doTryExcept(return(expr), parentenv) invisible(except) } As you can see, the tryExcept function uses a simplified version of the tryCatch architecture, bu...
2005 Oct 10
2
Catching warning and error output
...o make them look normal. Also: Can I be sure, that all warnings (i.e. even from C-code) are signalled as conditions? I'm afraid I do not fully understand the internal going-ons, here. If all else fails, I'll have to use this, but I'm not very happy with this. 3b) Use ".Internal (.addCondHands (...))" once to set up persistent handlers: This worked fine, when testing it in the R-console. However, in my GUI, calls are actually handled using R_tryEval (..., R_GlobalEnv, ...). It seems the condition handlers do not carry over between two successive calls of R_tryEval. So effectivel...
2018 Nov 22
2
[tryExcept] New try Function
Hi everyone, When dealing with errors, sometimes I want to run a bunch of code when an error occurs. For now I usually use a structure such as: res <- tryCatch(expr, error = function(cond) cond) # or try(expr) if (inherits(res, ?error?)) # or inherits(res, ?try-error?) # a bunch of code I though it would be useful to have a function that does this naturally, so I came up with the attached