# Why doesn't rescue catch Exception by default?

**URL:** <https://www.ruby-forum.com/t/why-doesnt-rescue-catch-exception-by-default/107487>\
**Category:** Ruby\
**Created:** [June 22, 2007, 6:04am UTC](https://www.ruby-forum.com/t/why-doesnt-rescue-catch-exception-by-default/107487 "2007-06-22T06:04:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [June 22, 2007, 6:04am UTC](https://www.ruby-forum.com/t/why-doesnt-rescue-catch-exception-by-default/107487/1 "2007-06-22T06:04:43Z")

</div>

From:  
[http://www.rubycentral.com/book/tut\_exceptions.html](http://www.rubycentral.com/book/tut_exceptions.html)

— BEGIN  
When you need to raise an exception, you can use one of the built-in  
Exception classes, or you can create one of your own. If you create your  
own, you might want to make it a subclass of StandardError or one of its  
children. If you don’t, your exception won’t be caught by default.  
— END

My question is _why_ doesn’t it handle the most generalized class,  
Exception, by default? What’s the logic behind this?

---

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [June 22, 2007, 10:13am UTC](https://www.ruby-forum.com/t/why-doesnt-rescue-catch-exception-by-default/107487/2 "2007-06-22T10:13:46Z")

</div>

On Jun 21, 2007, at 21:04, Seth wrote:

> — END
> 
> My question is _why_ doesn’t it handle the most generalized class,  
> Exception, by default? What’s the logic behind this?

From [http://www.zenspider.com/Languages/Ruby/QuickRef.html#34:](http://www.zenspider.com/Languages/Ruby/QuickRef.html#34:)

Exception  
NoMemoryError  
ScriptError  
LoadError  
NotImplementedError  
SyntaxError  
SignalException  
Interrupt  
StandardError (default for rescue)  
[…]  
SystemExit  
fatal

You don’t want to rescue any of these other exceptions (besides  
StandardError and friends) unless you really know what you’re doing.

Don’t create your own exception classes by subclassing Exception  
directly, subclass the closest matching exception class, or subclass  
RuntimeError or StandardError.
