Descendents of class Warning are used to raise structured warnings. They programmers to explicitly supress certain kinds of warnings and provide additional information in contrast to the plain warn method. They implement an Exception-like interface and carry information about the warning – its type (the warning’s class name), an optional descriptive string, and optional traceback information. Programs may subclass Warning to add additional information.
Large portions of this class’s documentation are taken from the Exception RDoc.
Construct a new Warning object, optionally passing in a message.
# File lib/structured_warnings/warning.rb, line 13 def initialize(message = nil) @message = message @backtrace = caller(1) end
Returns any backtrace associated with the warning. The backtrace is an array of strings, each containing either “filename:lineNo: in `method”‘ or “filename:lineNo.”
# File lib/structured_warnings/warning.rb, line 25 def backtrace @backtrace end
Return this warning’s class name and message
# File lib/structured_warnings/warning.rb, line 44 def inspect "#<#{self.class}: #{self}>" end
Sets the backtrace information associated with warning. The argument must be an array of String objects in the format described in Exception#backtrace.
# File lib/structured_warnings/warning.rb, line 32 def set_backtrace(backtrace) @backtrace = backtrace end
Generated with the Darkfish Rdoc Generator 2.