From richierocks at gmail.com  Thu May  5 08:59:40 2016
From: richierocks at gmail.com (Richard Cotton)
Date: Thu, 5 May 2016 09:59:40 +0300
Subject: [Rd] Is it possible to retrieve the last error? (not error
	*message*)
In-Reply-To: <CAFDcVCSGG-wpsGFQ5X93z8caC+6VapVqYrX1iA9+55NuLW_SGg@mail.gmail.com>
References: <CAFDcVCSGG-wpsGFQ5X93z8caC+6VapVqYrX1iA9+55NuLW_SGg@mail.gmail.com>
Message-ID: <CAPp_+=cHnWSxZz4fG3NHPA97cYwmXV-Cw1=_-DzTCzQhFcB17A@mail.gmail.com>

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
baseenv()$.Traceback with earlier version of R.

On 4 May 2016 at 22:41, Henrik Bengtsson <henrik.bengtsson at gmail.com> wrote:
> Hi,
>
> at the R prompt, is it possible to retrieve the last error (as in
> condition object of class "error")?
>
> I'm not asking for geterrmessage(), which only returns the error
> message (as a character string).  I'm basically looking for a
> .Last.error or .Last.condition, analogously to .Last.value for values,
> which can be used when it is "too late" (not possible) to go back an
> use try()/tryCatch().
>
> Thanks,
>
> Henrik
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Regards,
Richie

Learning R
4dpiecharts.com



[Rd] Is it possible to retrieve the last error? (not error *message*)
Richard Cotton