similar to: Is it possible to retrieve the last error? (not error *message*)

Displaying 20 results from an estimated 6000 matches similar to: "Is it possible to retrieve the last error? (not error *message*)"

2004 Mar 11
2
No traceback available when using try(...)
Hello, 1. The Situation : ------------------------ The stack traceback is not available when error ouccured in a try(....) -- test.R -------------------------------- f<-function(a){ return ( log(a) ) } try(f("A")) traceback() ------------------------------------------- I get the following message : > try(f("A")) Error in log(x) : Non-numeric argument to mathematical
2019 Mar 02
1
stopifnot
A private reply by Martin made me realize that I was wrong about stopifnot(exprs=TRUE) . It actually works fine. I apologize. What I tried and was failed was stopifnot(exprs=T) . Error in exprs[[1]] : object of type 'symbol' is not subsettable The shortcut assert <- function(exprs) stopifnot(exprs = exprs) mentioned in "Warning" section of the documentation similarly fails
2019 Mar 05
2
stopifnot
Another possible shortcut definition: assert <- function(exprs) do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame())) After thinking again, I propose to use ??? ? ? stop(simpleError(msg, call = if(p <- sys.parent()) sys.call(p))) - It seems that the call is the call of the frame where stopifnot(...) is evaluated. Because that is the correct context, I
2017 Dec 01
3
tryCatch in on.exit()
The following example involves a function whose on.exit() expression both generates an error and catches the error. The body of the function also generates an error. When calling the function wrapped in a tryCatch, should that tryCatch's error function be given the error from the body of the function, since the one from the on.exit has already been dealt with? Currently the outer tryCatch
2019 Feb 27
1
stopifnot
My points: - The 'withCallingHandlers' construct that is used in current 'stopifnot' code has no effect. Without it, the warning message is the same. The overridden warning is not raised. The original warning stays. - Overriding call in error and warning to 'cl.i' doesn't always give better outcome. The original call may be "narrower" than 'cl.i'. I
2018 Feb 22
2
Problem with geterrmessage()
Luke Thanks ? I revised the code to: ERRORMESSAGE <- try(source(USERSCRIPTFILE, local=T), silent=T) print(ERRORMESSAGE) now returns: $value [1] 0 $visible [1] FALSE Not clear what to make of that. Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone / Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com > On Feb 22, 2018, at 12:45 PM, luke-tierney at
2004 Mar 09
4
how to use conditional statements to handle exceptions?
Hello, I have a problem to handle the following statements. for(i in [1:3]) { file=paste("file", i, ".dat") bb <- read.table(file) x11() plot(bb) dev.off() } When the input .dat file is empty, the program stops running and an error message appears. Could someone tell me how to handle this exception? Thanks
2018 Feb 22
2
Problem with geterrmessage()
R 3.4.3 OS X Colleagues I have a 20K line script in which I encounter an unexpected problem. If the script detects presence of a particular file USERCODE.txt, it executes: source(?USERCODE.txt?) If that file is not present, the script executes without a problem. There might be syntax errors in USERCODE.txt; therefore, the code above is embedded in a try command:
2008 Sep 10
1
help: error handling in try
First time to post and searched archive for this problem with no clue. My version is 2.5.1. Below is a function to check if a given date is a valid date to a given date function object. It uses try (also tried tryCatch but with same problem). When given an invalid date, I am hoping try will generate en error message which would be picked up by the geterrmessage and thus expecting a false result.
2019 Jun 08
2
Determining the exit code of an "almost finished" R script
Dear All, I'm using "reg.finalizer" in a function that is to be called in R scripts to do some cleanup on success. I have not found a way to run the function only if the script run without errors, so when the exit code is expected to be 0. What I've tried is checking "geterrmessage()", but unfortunately it's not perfect: if an error was handled with eg
2009 Mar 20
1
sprintf causes a segfault (PR#13613)
Full_Name: Wacek Kusnierczyk Version: 2.8.0 and 2.10.0 r48163 OS: Ubuntu 8.04 Linux 32bit Submission from: (NULL) (129.241.198.172) the following code illustrates a problem with sprintf which consistently causes a segfault when applied to certain type of arguments. it also shows inconsistent consequences of the segfault: (e = tryCatch(stop(), error=identity)) # e is an error object
2005 Sep 07
1
Tracebacks with tryCatch() and withCallingHandlers()?
When batch processing analysis, I use tryCatch() for failure handling and to prevent unwanted interrupts. I write detailed progress to log file and conditions (warnings and errors) are written to the same log file immediately by using withCallingHandlers(..., condition=function(c) cat(c, file=logFile)). However, I would also like to write the call stack to the log file to further simplify
2018 Feb 22
0
Problem with geterrmessage()
Only the default error handler puts the error message in a buffer where it can be retrieved with geterrmessage. try() replaces the default error handler. Either look at the value returned by try() or use tryCatch with conditionMessage. Best, luke On Thu, 22 Feb 2018, Dennis Fisher wrote: > R 3.4.3 > OS X > > Colleagues > > I have a 20K line script in which I encounter an
2018 Feb 21
1
Checking for a proper "stop" statement...
Folks: Consider the following two use cases: goodfunction <- function() { stop("Something went wrong..." } # vs. badfunction <- function() { notgood() } Is there a way for me to test if the functions make use of a stop() statement WITHOUT modifying the stop() output (assume I can't mod the function containing the stop() statement itself)? For "goodfunction" the
2016 May 05
0
Is it possible to retrieve the last error? (not error *message*)
I wondered the same thing a few days ago. https://stackoverflow.com/questions/36966036/how-to-get-the-last-error The here's the solution from that discussion: get_last_error <- function() { tr <- .traceback() if(length(tr) == 0) { return(NULL) } tryCatch(eval(parse(text = tr[[1]])), error = identity) } Note that it uses .traceback() from R 3.3.0; you'll have to use
2010 Aug 22
2
on abort error, always show call stack?
Dear R Wizards---is it possible to get R to show its current call stack (sys.calls()) upon an error abort? I don't use ESS for execution, and it is often not obvious how to locate how I triggered an error in an R internal function. Seeing the call stack would make this easier. (right now, I sprinkle "cat" statements everywhere, just to locate the line where the error appears.) Of
2019 Jun 08
2
Determining the exit code of an "almost finished" R script
On Sat, Jun 8, 2019 at 2:13 PM Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > > On 08/06/2019 7:42 a.m., Gergely Dar?czi wrote: > > Dear All, > > > > I'm using "reg.finalizer" in a function that is to be called in R scripts > > to do some cleanup on success. I have not found a way to run the function > > only if the script run without
2019 Mar 31
3
stopifnot
Ah, with R 3.5.0 or R 3.4.2, but not with R 3.3.1, 'eval' inside 'for' makes compiled version behave like non-compiled version. options(error = expression(NULL)) library(compiler) enableJIT(0) f <- function(x) for (i in 1) {x; eval(expression(i))} f(is.numeric(y)) # Error: object 'y' not found fc <- cmpfun(f) fc(is.numeric(y)) # Error: object 'y' not found
2015 Sep 10
2
Using IDs to suppress specific messages and warnings
The suppressMessages and suppressWarnings functions currently suppress all the message or warnings that are generated by the input expression. The ability to suppress only specific messages or warnings is sometimes useful, particularly for cases like file import where there are lots of things that can go wrong. Suppressing only messages that match a regular expression has rightly been rejected
2009 Feb 04
2
Capturing all warnings (with messages)
Dear all, For an open-source project that I'm working on (1), which uses R for all its heavy lifting but includes a wrapper shell script, I was hoping to find a way to capture all warnings (and, in fact, errors too), and handle them in my own way. I realise I can do this for a single expression using something like: > f <- function(w) print(w$message) >