# Error handling and recovery

**URL:** <https://www.ruby-forum.com/t/error-handling-and-recovery/61976>\
**Category:** Ruby\
**Created:** [May 30, 2006, 2:34pm UTC](https://www.ruby-forum.com/t/error-handling-and-recovery/61976 "2006-05-30T14:34:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkspence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pkspence](https://www.ruby-forum.com/u/pkspence)\
**Post date:** [May 30, 2006, 2:34pm UTC](https://www.ruby-forum.com/t/error-handling-and-recovery/61976/1 "2006-05-30T14:34:30Z")

</div>

I have a module which specifically deals with connections to a MSSQL  
database. Contained in this module is a method which actually opens the  
connection. The code contained in the method is wrapped w/in a  
begin…rescue…end block. If any sort of an error occurs, the code in  
the rescue block is supposed to to re-raise the error back to the  
calling module and let it deal with error reporting/recovery. The  
problem is that the code in the rescue block of the module that’s  
calling the method to open the connection is not running. I’d understood  
that Ruby would search back thru the callstack looking for a rescue  
block when an error was raised. Obviously I’m missing something here!

---

<div class="post-metadata">

**Author:** ![pkspence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@pkspence](https://www.ruby-forum.com/u/pkspence)\
**Post date:** [May 30, 2006, 3:43pm UTC](https://www.ruby-forum.com/t/error-handling-and-recovery/61976/2 "2006-05-30T15:43:29Z")

</div>

On 5/30/06, Patrick S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
[Error not being re-raised]

> Obviously I’m missing something here!

And we’re missing some code. Code makes it a lot easier to understand  
what you’re doing, how you’re doing it, and what you’re doing wrong.

Peace.

nikolai
