Is it possible to define an exception handler for any unhandled exceptions? Wrapping my entire code block in a begin/rescue/end block feels messy.
Is it possible to define an exception handler for any unhandled exceptions? Wrapping my
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
How about using at_exit? It should be called even when an exception occurs and you can log the last exception using $!
Here is an example:
http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-at_exit