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

  • Home
  • SEARCH
  • 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 8849697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:43:09+00:00 2026-06-14T12:43:09+00:00

How can I capture an exception from another thread? I want to do this

  • 0

How can I capture an exception from another thread?

  • I want to do this for some particular thread, and not for other threads, so I cannot turn on abort_on_exception to true.
  • I want to do something in the main thread with the exception, so I cannot simply do puts, pp, etc. with the exception within the thread that raised in exception.

I found an answer in How to get error messages from ruby threads that suggests using catch, and I think that is the way I want to go, but I cannot not fully figure out how to do it. Or is there a better way? I also found an answer suggesting to use Queue class, but have concern that it may be overkill.

  • 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-14T12:43:11+00:00Added an answer on June 14, 2026 at 12:43 pm

    If you turn on abort_on_exception then you won’t have a chance to catch it. You can, however, leave that off and simply catch it when you do the join operation on your thread.

    thread = Thread.new do
      raise "Uh oh"
    end
    
    begin
      thread.join
    rescue => e
      puts "Caught exception: #{e}"
    end
    

    The alternative is to make the thread catch its own exception and save it somewhere you can fetch it from later. For instance:

    exceptions = { }
    
    Thread.new do
      begin
        raise "Uh oh"
      rescue => e
        exceptions[Thread.current] = e
      end
    end
    
    sleep(1)
    
    puts exceptions.inspect
    # => {#<Thread:0x007f9832889920 dead>=>#<RuntimeError: Uh oh>}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related to another thread, you can read here: Forms authentication with
I'm trying to be able to have a global exception capture where I can
i can capture image using avfoundation.framework as shown in AVCam Demo but i want
Windows's Snipping tool can capture the screen, but sometimes I want to capture the
Basically just looking to see if you can capture an image from the webcam
I would like to make a php script that can capture a page from
I'm using Thread::Pool::Simple to create a few working threads. Each working thread does some
I'm trying to develop an App that amongst other things can record videos from
How I can capture browser restore/maximize event in jQuery or javascript? We can use
Could someone tell me how I can capture a NSParseErrorException? The Situation: my app

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.