Exception: MultiXML::ParserLoadError
- Inherits:
-
ArgumentError
- Object
- ArgumentError
- MultiXML::ParserLoadError
- Defined in:
- lib/multi_xml/errors.rb
Overview
Raised when a parser cannot be loaded or is not recognized
Covers three failure modes in one typed error, so callers can catch all "I couldn't even get to parsing" problems with one rescue:
- Invalid spec type (not a Symbol, String, or Module)
- LoadError from requiring the parser file
- A custom parser that doesn't satisfy the contract (no .parse method or no parse_error method / ParseError constant)
Matches the role of MultiJSON::AdapterError.
Class Method Summary collapse
-
.build(original_exception) ⇒ ParserLoadError
Build a ParserLoadError from an original exception.
Instance Method Summary collapse
-
#initialize(message = nil, cause: nil) ⇒ ParserLoadError
constructor
Create a new ParserLoadError.
Constructor Details
#initialize(message = nil, cause: nil) ⇒ ParserLoadError
Create a new ParserLoadError
88 89 90 91 |
# File 'lib/multi_xml/errors.rb', line 88 def initialize( = nil, cause: nil) super() set_backtrace(cause.backtrace) if cause end |
Class Method Details
.build(original_exception) ⇒ ParserLoadError
Build a ParserLoadError from an original exception
The original exception's class name is included in the message so
a downstream consumer reading just the ParserLoadError can tell
whether the underlying failure was a LoadError, an
ArgumentError from the spec validator, or some other class
without having to look at error.cause separately.
106 107 108 109 110 111 112 |
# File 'lib/multi_xml/errors.rb', line 106 def self.build(original_exception) new( "Did not recognize your parser specification " \ "(#{original_exception.class}: #{original_exception.}).", cause: original_exception ) end |