Top

Print Exception Class Hieararchy


Ruby / Rails Code
+ 0 likes
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 

Introduction

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,039
 
Ruby / Rails Snippet:  Print Exception Class Hieararchy
Posted on Sep 19, 2005 5:30 am
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 on Oct 6, 2005 4:04 am
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 on Nov 10, 2005 4:58 pm
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