Raising Excepitons

J

John W. Long

Hi,

I'm curious. In code I often raise my own exceptions with:

raise "custom error message"

When is it a good idea to subclass and create my own error class? So far
I've never needed to pass along custom information (other than the message).
It seems like it might make testing better:

assert_raises(MyError) { ... }

instead of:

assert_raises(RuntimeError) { ... }

Are there any other advantages? Are there times when it's convention to
create your own?

___________________
John Long
www.wiseheartdesign.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,139
Messages
2,570,805
Members
47,356
Latest member
Tommyhotly

Latest Threads

Top