From: Tom Copeland Date: 2006-11-28T11:08:58+09:00 Subject: Re: Help me design my exception classes On Tue, 2006-11-28 at 10:07 +0900, J. B. Rainsberger wrote: > Being a Java programmer learning Ruby, Welcome! Your JUnit book rocks. > What's the corresponding exception class in Ruby to Java's generic > RuntimeException. Is it RuntimeError? StandardError? Exception? Does > anyone want to tell me I'm nuts and show me a more "standard" way of > designing exceptions in Ruby? I usually rescue a generic Exception: =========== $ irb irb(main):001:0> begin irb(main):002:1* raise "hey" irb(main):003:1> rescue Exception => e irb(main):004:1> puts e.class irb(main):005:1> end RuntimeError => nil =========== You can create your own exceptions, of course: =========== irb(main):006:0> class MyException < Exception irb(main):007:1> def initialize ; puts "hello" ; super ; end irb(main):008:1> end => nil irb(main):009:0> MyException.new hello => # =========== Yours, Tom