From: ts Date: 2001-11-07T20:58:13+09:00 Subject: [ruby-talk:24501] Re: List of Exception classes >>>>> "R" == Rube writes: R> I mean no disrespect, but the online version of the PP book doesn't R> list the hierarchy ("figure not available"). Ought one be required to R> purchase a commercial text to obtain the exception classes in the ruby R> language? This seems like information that ought to be freely R> available- requiring dead-tree reference material to learn something R> this basic about the language will discourage it's popularity, and R> ultimately, the sale of ruby texts. Well, ruby is a programming language that means that it's OK to use it for writing programs :-) pigeon% cat b.rb #!/usr/bin/ruby class Hier < Hash def initialize klass = Object @kl, cl = klass ObjectSpace.each_object(Class) do |obj| if obj < klass anc = obj.ancestors (anc.shift && anc).each {|cl| break if cl.kind_of? Class } (self[cl] ||= []).push obj end end end def display cl = @kl, level = 0 print " " * level, cl, "\n" (self[cl] || []).each {|obj| display obj, level + 1} end end Hier.new(Exception).display ScriptError pigeon% b.rb ScriptError NotImplementedError LoadError NameError SyntaxError pigeon% Guy Decoux