Displaying 4 results from an estimated 4 matches for "simplecondit".
2005 Oct 18
0
tryCatch, simpleCondition question
Hi,
I'm trying to learn how to use the tryCatch condition system and am
confused about the behavior when I set the call arg of a
simpleCondition.
I want to catch an error if it meets a certain criteria and otherwise
reraise it. I want the error message to indicate the function in
which the error occured (and not mention tryCatch).
Wanted:
> g("foo") ## error caught
[1] "caught foo"
> g("o...
2006 Mar 14
1
New simpleExit() condition (Was: Re: Can example() code stop the example without generating an error?)
...keep the code clean and I want to avoid nested if
statements. Further conditions down the stream would make the code
quite ugly. Pretty much for the same reason you use 'return()' and
'break'.
A nicer and more general solution is to have a subclass "simpleExit"
of "simpleCondition" and make source() catch such signals via
tryCatch(..., simpleExit=function(se) {...}). Here is a complete
example:
simpleExit <- function(...) {
cond <- simpleCondition(...)
class(cond) <- c("simpleExit", class(cond))
cond
}
exit <- function(...) {
invisibl...
2013 Feb 07
4
Hard Stop?
is it possible to throw a stop() that is so hard that it will escape
even tryCatch?
/iaw
----
Ivo Welch (ivo.welch at gmail.com)
2007 Aug 27
0
Suggestion: Add simpleExit condition
...e("foo")} { }
statement, but the above is to avoid such nested code, especially in
example code, cf. return() and break.
Here are the details to get this working:
1. Define a new condition class similar to simpleWarning() and simpleError():
simpleExit <- function(...) {
cond <- simpleCondition(...)
class(cond) <- c("simpleExit", class(cond)) cond
}
2. Setup a method to generate such a condition similar to warning() and stop():
exit <- function(...) {
invisible(signalCondition(simpleExit(...))) }
}
3. That is the basic framework. We can then use tryCatch() to c...