Print Exception Class Hieararchy

By dr_bob on Sep 19, 2005

Prints an indented exception class hiearchy.

require 'pp'
tree = (cr = lambda {|h,k| h[k] = &cr})[{},nil]
ObjectSpace.each_object(Class) {|cl| if cl.ancestors.include? Exception
then cl.ancestors.reverse.inject(tree){|tr,cl| tr[cl]} end}
pp tree


Sign in to comment.
log2   -  Nov 10, 2005

I think he means what EXACTLY does it do.. not everyone knows what a class hierarchy is

dr_bob   -  Oct 06, 2005

I\'ve described what it is for. Do you mean an explanation how it works?

Hawkee   -  Sep 19, 2005

Thanks for the snippet dr bob, but maybe you can add some layman terms to your description so newbies might know what this is for.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.