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
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