search for: signalcondit

Displaying 20 results from an estimated 24 matches for "signalcondit".

2003 Nov 08
1
signalCondition
Does signalCondition() only work within try-catch blocks? I expected: testSignal <- function() { error <- simpleError("An error!") signalCondition(error) } to do the same thing as testStop <- function() { error <- simpleError("An error!") stop(error) } but testSig...
2007 Feb 19
2
"try"ing to understand condition handling
I'm confused by the page documenting tryCatch and friends. I think it describes 3 separate mechanisms: tryCatch (in which control returns to the invoking tryCatch), withCallHandlers (in which control goes up to the calling handler/s but then continues from the point at which signalCondition() was invoked), and withRestarts (I can't tell where control ends up). For tryCatch the docs say the arguments ... provide handlers, and that these are matched to the condition. It appears that matching works by providing entries in ... as named arguments, and the handler matches if the na...
2012 Feb 29
0
Alternative to .Internal(.dfltStop(msg, call))?
...t* part of the getMessage() of the 'error' condition object, which is important when catching the error in signal handlers. Here is a stub what is done, leaving out the details how to retrieve the stack trace (call history): throw <- function(msg, ...) { cond <- simpleError(msg); signalCondition(cond); # A dummy stracktrack / call history stackTraceStr <- "at foo()\nat bar()\n"; call <- NULL; # Also a dummy for this example # If the condition is not caught, do a "full stop" showing error message and stacktrace fullmsg <- paste(msg, "\n&quot...
2018 Jul 28
4
re-throwing an interrupt condition
Anyone knows a way to re-throw a caught interrupt condition, so that it behaves just like the original one? I.e. no error message is printed, but the execution is stopped of course. With just calling stop in the error handler, it prints the error message, or, if there is no error message (like in the original interrupt condition), another error happens. tryCatch(Sys.sleep(100), interrupt =
2018 Jul 28
0
re-throwing an interrupt condition
The internal code does more or less signalCondition(e) ## allows for (another) handler cat("\n") ## cleans up console invokeRestart("abort") ## jump to 'abort' restart if not handled [for back compatibility it also runs the error option code if that is set, but that may go away eventually]....
2009 Apr 14
0
top level condition handlers
...s and restarts, so that I don't explicit calls to withCallingHandlers and withRestarts in many places: For example : > customError function( message ){ err <- simpleError( message ) class( err ) <- c( "customError", class( err) ) err } > withCallingHandlers( { signalCondition(customError( "ouch")) } , customError = function(e) cat( "gotcha : ", e$message, "\n" ) ) gotcha : ouch NULL I'd like to be able to do something like this: > topLevelCallingHandlers( customError = function(e) cat( "gotcha : ", e$message, &quot...
2006 Mar 14
1
New simpleExit() condition (Was: Re: Can example() code stop the example without generating an error?)
...n" 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(...) { invisible(signalCondition(simpleExit(...))) } evalWithExit <- function(...) { tryCatch(..., simpleExit=function(cond) cond) } sourceWithExit <- function(...) { evalWithExit(source(...)) } Examples: > evalWithExit({cat("Hi\n");exit("Bye!");cat("there\n")}); cat("bye\n&q...
2008 Aug 27
1
S4 coercion
...uot;, target "TSPostgreSQLConnection#integer" (the first of the signatures shown will be used) PostgreSQLConnection#integer dbObjectId#integer > traceback() 15: doWithOneRestart(return(expr), restart) 14: withOneRestart(expr, restarts[[1]]) 13: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call), msg, call)) .Internal(.dfltWarn(msg, call)) }, muffleWarning = function() NULL) 12: .signalSimpleWarning("Ambiguous method selection for \"coerce\", target \"TSPostgreSQLConnection#integer\" (the first of the signatures sh...
2008 Jun 03
1
R-2.7.0 make check failure
...+1))) / factorial(k)) > k <- -1:6 > cbind(k=k, choose(1/2, k), mychoose(1/2, k)) *** caught segfault *** address 0x200, cause 'memory not mapped' Traceback: 1: doWithOneRestart(return(expr), restart) 2: withOneRestart(expr, restarts[[1]]) 3: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call), msg, call)) .Internal(.dfltWarn(msg, call))}, muffleWarning = function() NULL) 4: .signalSimpleWarning("NaNs produced", quote(gamma(x + 1))) 5: factorial(k) 6: ifelse(k <= 0, (k == 0), sapply(k, function(k) prod(r:(r - k + 1)))/fa...
2023 Feb 19
2
R: determine if `suppressMessages()` has been invoked
...e" restart provided by message() itself above. We can use the fact that the availability of the "muffleMessage" restart is a documented detail and check whether signalling a "message" condition will call this restart: are_messages_suppressed <- function() withRestarts( { signalCondition(simpleMessage('')) # we stay here if restart is not invoked FALSE }, muffleMessage = function() # we jump here if restart is invoked TRUE ) are_messages_suppressed() # [1] FALSE suppressMessages(are_messages_suppressed()) # [1] TRUE I don't think I understand handlers and restarts en...
2019 Jun 21
2
Suggested Patch: Library returns matching installed packages when typo present
Hi Luke, Thank you for your response. On 6/21/19 10:56 AM, Tierney, Luke wrote: Thanks for the suggestion. However I don't think it is the right way to go. I also don't care for what install.packages() does. Signaling a warning and then an error means someone has to catch both the error and the warning, or suppress the warning, in order to handle the error programmatically. I do care
2017 Jan 02
1
utils::ls.str(): Partial argument name 'digits' to seq() (should be digits.d?)
...n = 2) > x <- 1 > ls.str() x : Error in str.default(o, ...) : (converted from warning) partial argument match of 'digits' to 'digits.d' > traceback() 10: doWithOneRestart(return(expr), restart) 9: withOneRestart(expr, restarts[[1L]]) 8: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call), msg, call)) .Internal(.dfltWarn(msg, call)) }, muffleWarning = function() NULL) 7: .signalSimpleWarning("partial argument match of 'digits' to 'digits.d'", quote(str.default(o, ...))) 6: str.default(o, ...) 5: str(o,...
2023 Feb 19
1
R: determine if `suppressMessages()` has been invoked
Hi all, I would like to create a function that detects if suppressMessages has been invoked upon running that same function. I was looking through {https://cran.r-project.org/doc/manuals/r-release/R-ints.html}, but I haven't found an answer. I do not understand **how** suppressMessages works. I have not received an answer on SO
2007 Aug 27
0
Suggestion: Add simpleExit condition
...ilar 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 catch and return upon a simpleExit as follows: evalWithExit <- function(...) { tryCatch(..., simpleExit=function(cond) cond) } } Then it is matter of flavor if one wants to update source() with an argumen...
2009 Sep 02
1
Tracebacks & try
Hi all, The help for traceback states: Errors which are caught _via_ 'try' or 'tryCatch' do not generate a traceback, so what is printed is the call sequence for the last uncaught error, and not necessarily for the last error. Is there any way to get a traceback (or something similar) for an error raised inside a try block? Regards, Hadley -- http://had.co.nz/
2017 Jan 04
0
cat(s, file): infinite loop of "invalid char string in output conversion" warnings with UTF-8 encoding
..."factor" %in% attrib[["class", exact = TRUE]] 7: structure(list(message = as.character(message), call = call), class = class) 6: simpleWarning(msg, call) 5: doWithOneRestart(return(expr), restart) 4: withOneRestart(expr, restarts[[1L]]) 3: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call), msg, call)) .Internal(.dfltWarn(msg, call)) }, muffleWarning = function() NULL) 2: .signalSimpleWarning("invalid char string in output conversion", quote(cat(s, file = tempfile()))) 1: cat(s, file = tempfile()) ## SOME TROUBLESHOO...
2023 Apr 30
0
Forcing a PROTECT Bug to Occur
...anything! > > gctorture(TRUE) > > z() > > ?*** caught segfault *** > address 0x55a68ce57f90, cause 'memory not mapped' > > Traceback: > ?1: doWithOneRestart(return(expr), restart) > ?2: withOneRestart(expr, restarts[[1L]]) > ?3: withRestarts({ ?.Internal(.signalCondition(simpleWarning(msg, > call), msg, ? ? call)) ? ?.Internal(.dfltWarn(msg, call))}, > muffleWarning = function() NULL) > ?4: .signalSimpleWarning("your C program does not return anything!", ? > ? base::quote(z())) > ?5: .Primitive(".Call")(<pointer: 0x7f2a02...
2008 Jan 18
0
more help needed Re: communicate from Rterm
...calling R from VBA. Now I want to use tryCatch to output the error to a text file and exit gracefully. My expression will be source("file.r") and that will contain file I/O and db connect+query. to exemplify I am trying with tryCatch(read.csv(nosuchfile.csv),error=function(e){print (signalCondition(e)},finally=print("graceful exit")) and not only it does not work but prints me a warning, so handling definitely fails. Please, help or refer to tryCatch examples with real handlers. I could not get much out of the examples in the help file. Thanks everybody ----Original Message...
2013 Feb 01
1
Was confused with options(error = expression(NULL)) in example(stop)
In example for function 'stop' in R, there is options(error = expression(NULL)) with comment # don't stop on stop(.) << Use with CARE! >> I was interested, wanted to know how "don't stop on stop(.)" was. So, I tried it. Typing example(stop) at the R prompt and pressing ENTER give this. > example(stop) stop> options(error = expression(NULL))
2012 Jul 25
2
reshape -> reshape 2: function cast changed?
Hi, I used to use reshape and moved to reshape2 (R 2.15.1). Now I tried some of my older scripts and was surprised that my cast function wasn't working like before. What I did/want to do: 1) Melt a dataframe based on a vector specifying column names as measure.vars. Thats working so far: dfm <- melt(df, measure.vars=n, variable_name = "species", na.rm = FALSE) 2) Recast the