Closed tfausak closed 10 years ago
Should the error be in a serialized format?
It is, in a way. The problem is that #inspect
doesn't always give you enough information to rebuild the exception.
Here's a more complete failing example:
>> CustomError = Class.new(StandardError)
=> CustomError
>> json = Stoplight::Failure.new(CustomError.new('custom message')).to_json
=> "{\"error\":\"#<CustomError: custom message>\",\"time\":\"2014-09-12 11:42:31 -0500\"}"
>> Object.send(:remove_const, :CustomError)
=> CustomError
>> Stoplight::Failure.from_json(json)
NameError: uninitialized constant CustomError
It's possible that the error class in the JSON isn't in scope when converting from JSON.