Top

Print Exception Class Hieararchy


Ruby / Rails Code

Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Sep 19, 2005
Last Updated  Sep 19, 2005
Tags  class  exception  hiearchy  tree 

Description

Prints an indented exception class hiearchy.

Grab the Code

require 'pp'
tree = (cr = lambda {|h,k| h[k] = Hash.new &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
 

Comments

  (3)  RSS
Hawkee
Comments: 1,122
 
Ruby / Rails Snippet:  Print Exception Class Hieararchy
Posted 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.
dr_bob
Comments: 1
 
Ruby / Rails Snippet:  Print Exception Class Hieararchy
Posted Oct 06, 2005
I've described what it is for. Do you mean an explanation how it works?
log2
Comments: 51
 
Ruby / Rails Snippet:  Print Exception Class Hieararchy
Posted Nov 10, 2005
I think he means what EXACTLY does it do.. not everyone knows what a class hierarchy is

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  

Bottom