Exception: WLang::Error
- Inherits:
-
StandardError
- Object
- StandardError
- WLang::Error
- Defined in:
- lib/wlang/errors.rb
Overview
Main error of all WLang errors.
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) cause
Optional cause (other lower level exception).
-
- (Object) parser_state
The parser state whe this error has been raised.
Instance Method Summary (collapse)
-
- (Error) initialize(msg = nil, parser_state = nil, cause = nil)
constructor
Creates an error instance with a given parser state.
-
- (Object) wlang_backtrace
Returns a friendly wlang backtrace.
Constructor Details
- (Error) initialize(msg = nil, parser_state = nil, cause = nil)
Creates an error instance with a given parser state
13 14 15 16 17 18 19 20 |
# File 'lib/wlang/errors.rb', line 13 def initialize(msg = nil, parser_state = nil, cause = nil) raise ArgumentError, "msg expected to be nil or a String" unless (msg.nil? or String===msg) raise ArgumentError, "parser_state expected to be nil or a State"\ unless (parser_state.nil? or ::WLang::Parser::State===parser_state) super(msg) @parser_state = parser_state @cause = cause end |
Instance Attribute Details
- (Object) cause
Optional cause (other lower level exception)
10 11 12 |
# File 'lib/wlang/errors.rb', line 10 def cause @cause end |
- (Object) parser_state
The parser state whe this error has been raised
7 8 9 |
# File 'lib/wlang/errors.rb', line 7 def parser_state @parser_state end |
Instance Method Details
- (Object) wlang_backtrace
Returns a friendly wlang backtrace
23 24 25 |
# File 'lib/wlang/errors.rb', line 23 def wlang_backtrace parser_state ? parser_state.backtrace : ["no backtrace information, sorry"] end |