Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:33:10+00:00 2026-06-07T08:33:10+00:00

When I use tryCatch , I can define an error handler and use conditionCall

  • 0

When I use tryCatch, I can define an error handler and use conditionCall to determine the call that caused the error. For instance,

tryCatch(
    eval(parse(text="prnit('Hello')")),
    error=function(e) {
      cl <- conditionCall(e)
      #...
    })

Can I get to the bad call on the R prompt? Until now, I found only this solution:

> err_hdl  <- function() {
    file1 <- tempfile("Rrawhist")
    savehistory(file1)
    rawhist <- readLines(file1)
    unlink(file1)

    cat("Error : ", tail(rawhist,1), "\n")
    return(TRUE)    
}
> options(error=err_hdl)
> prnit("Hello")

but I believe there must be a more straightforward way..

Any hint appreciated!

I put out a bounty. The first answer that implements the behaviour of the err_hdl function above without file I/O that is platform independent will be accepted.

Edit — the code above seems only to work on windows. I am looking for the input that raised the error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:33:12+00:00Added an answer on June 7, 2026 at 8:33 am

    It looks like dump.frames can be told not to dump to a file but rather to an object in the .GlobalEnv. However, I haven’t tested it on anything but a Mac. Would the following help?

    err_hdl2 <- function() {
      dump.frames("theErr", to.file = FALSE)
      cat("What happened?\n", attr(theErr,"error.message"), "\nOh.\n")
    }
    options(error = err_hdl2)
    
    > prnit(dt)
    Error: could not find function "prnit"
    What happened?
     Error: could not find function "prnit"
    
    Oh.
    

    There might be a drawback to creating the object theErr in the global environment, I suppose.

    > theErr
    $`function () 
    {
        dump.frames("theErr", to.file = FALSE)
        cat("What`
    <environment: 0x1030fe140>
    
    attr(,"error.message")
    [1] "Error: could not find function \"prnit\"\n"
    attr(,"class")
    [1] "dump.frames"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This article on MSDN states that you can use as many try catch blocks
Lets say I have a WCF service that a client can use to receive
How can I use try/catch/finally to make sure that the function will return value?
Is there anyway that I can use 2 try-all parameters in one same RouteBase?
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
If I use a try/catch and display a messagebox,I can only see the exception
In a tutorial I found that Unchecked Exception can't be handled by your code
If you are doing something trivial that if succeeds its a bonus but can
There is a method called foo that sometimes returns the following error: terminate called
I have code that is wrapped in try/catch block. I use typeof to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.