Please define a single base error. #125

Closed
ushis opened this Issue Feb 8, 2013 · 1 comment

Projects

None yet

2 participants

ushis commented Feb 8, 2013

Please define a single base error. At the moment there are two root exceptions:

# lib/psych.rb
RuntimeError > Psych::Exception > Psych::BadAlias

# lib/psych/syntax_error.rb
RuntimeError > Psych::Error > Psych::SyntaxError

If i want to catch all Psych errors, i have to write:

require 'psych'
require 'psych/syntax_error'

begin
  Psych.load(yaml)
rescue Psych::Exception, Psych::Error => e
  omg e
end

It would be way nicer to just require 'psych' and rescue Psych::Error.

Contributor
sheerun commented Feb 27, 2013

+1

@tenderlove tenderlove added a commit that referenced this issue Apr 5, 2013
@tenderlove tenderlove * ext/psych/lib/psych/exception.rb: there should be only one exception
  base class. Fixes tenderlove/psych #125
* ext/psych/lib/psych.rb: require the correct exception class
* ext/psych/lib/psych/syntax_error.rb: ditto
* ext/psych/lib/psych/visitors/to_ruby.rb: ditto

fixes #125
803653a
@tenderlove tenderlove closed this in 803653a Apr 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment