From: "John-Mason P. Shackelford" Date: 2005-10-18T00:49:54+09:00 Subject: YAML serialization of exceptions Why does the YAML library add a 'mesg' instance variable instead of re-implementing Exception#message to return @message? Any reason why we don't preserve the backtrace as well? (Relevant YAML code excepted below.) # File yaml/rubytypes.rb YAML.add_ruby_type( /^exception/ ) { |type, val| type, obj_class = YAML.read_type_class( type, Exception ) o = YAML.object_maker( obj_class, { 'mesg' => val.delete( 'message' ) } ) val.each_pair { |k,v| o.instance_variable_set("@#{k}", v) } o } # File yaml/rubytypes.rb, line 119 def Exception.yaml_new( klass, tag, val ) o = YAML.object_maker( klass, { 'mesg' => val.delete( 'message' ) } ) val.each_pair do |k,v| o.instance_variable_set("@#{k}", v) end o end Is the best way for me to support this functionality for a particular exception to call YAML.add_ruby_type() and to implement #to_yaml and #yaml_new methods on my exception? Thanks! 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