Module: MaRuKu::Errors
- Included in:
- MDElement
- Defined in:
- lib/maruku.rb,
lib/maruku/errors.rb
Constant Summary collapse
- FRAME_WIDTH =
75
Instance Method Summary collapse
-
#maruku_error(s, src = nil, con = nil) ⇒ Object
Properly handles a formatting error.
- #maruku_recover(s, src = nil, con = nil, recover = nil) ⇒ Object
- #raise_error(s) ⇒ Object
- #tell_user(s) ⇒ Object
Instance Method Details
#maruku_error(s, src = nil, con = nil) ⇒ Object
Properly handles a formatting error. All such errors go through this method.
The behavior depends on ‘MaRuKu::Globals`. If this is `:warning`, this prints the error to stderr (or `@error_stream` if it’s defined) and tries to continue. If ‘:on_error` is `:ignore`, this doesn’t print anything and tries to continue. If it’s ‘:raise`, this raises a MaRuKu::Exception.
By default, ‘:on_error` is set to `:warning`.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/maruku/errors.rb', line 24 def maruku_error(s, src=nil, con=nil, recover=nil) policy = get_setting(:on_error) case policy when :ignore when :raise raise_error create_frame(describe_error(s, src, con, recover)) when :warning tell_user create_frame(describe_error(s, src, con, recover)) else raise "Unknown on_error policy: #{policy.inspect}" end end |
#maruku_recover(s, src = nil, con = nil, recover = nil) ⇒ Object
38 39 40 |
# File 'lib/maruku/errors.rb', line 38 def maruku_recover(s, src=nil, con=nil, recover=nil) tell_user create_frame(describe_error(s, src, con, recover)) end |
#raise_error(s) ⇒ Object
42 43 44 |
# File 'lib/maruku/errors.rb', line 42 def raise_error(s) raise MaRuKu::Exception, s, caller end |
#tell_user(s) ⇒ Object
46 47 48 |
# File 'lib/maruku/errors.rb', line 46 def tell_user(s) (self.attributes[:error_stream] || $stderr) << s << "\n" end |