Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Why doesn't rescue catch Exception by default?
Seth
6/22/2007 4:05:00 AM
From:
http://www.rubycentral.com/book/tut_excep...
--- 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?
--
Posted via
http://www.ruby-...
.
1 Answer
Eric Hodel
6/22/2007 8:13:00 AM
0
On Jun 21, 2007, at 21:04, Seth wrote:
> From:
>
http://www.rubycentral.com/book/tut_excep...
>
> --- 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?
From
http://www.zenspider.com/Languages/Ruby/QuickR...
:
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.
--
Poor workers blame their tools. Good workers build better tools. The
best
workers get their tools to do the work for them. -- Syndicate Wars
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Why doesn't rescue catch Exception by default?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password