From: "John-Mason P. Shackelford" Date: 2005-10-18T02:04:59+09:00 Subject: Re: YAML serialization of exceptions Comments on the following alternative? # Add support for serialization class Exception def to_yaml( opts = {} ) YAML::quick_emit( self.object_id, opts ) { |out| out.map( self.to_yaml_type ) { |map| map.add( 'message', self.message ) map.add( 'backtrace', self.backtrace ) to_yaml_properties.each { |m| map.add( m[1..-1], instance_variable_get( m ) ) } } } end end YAML.add_ruby_type( /^exception/ ) { |type, val| type, obj_class = YAML.read_type_class( type, Exception ) o = YAML.object_maker( obj_class, val ) val.each_pair { |k,v| o.instance_variable_set("@#{k}", v) } class << o attr_reader :message, :backtrace end o } John-Mason Shackelford Software Developer Pearson Educational Measurement 2510 North Dodge St. Iowa City, IA 52245 ph. 319-354-9200x6214 john-mason.shackelford@pearson.com http://pearsonedmeasurement.com