Module: DbAgile::Environment::OnError
- Included in:
- DbAgile::Environment
- Defined in:
- lib/dbagile/environment/on_error.rb
Instance Attribute Summary collapse
-
#show_backtrace ⇒ Object
writeonly
Show backtrace on errors?.
Instance Method Summary collapse
-
#on_error(command, error) ⇒ Object
Handles an error that occured during command execution.
-
#show_backtrace? ⇒ Boolean
Shows the backtrace when an error occurs?.
Instance Attribute Details
#show_backtrace=(value) ⇒ Object (writeonly)
Show backtrace on errors?
6 7 8 |
# File 'lib/dbagile/environment/on_error.rb', line 6 def show_backtrace=(value) @show_backtrace = value end |
Instance Method Details
#on_error(command, error) ⇒ Object
Handles an error that occured during command execution.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dbagile/environment/on_error.rb', line 19 def on_error(command, error) case error when SystemExit when OptionParser::ParseError say(error., :red) display(command..to_s) when Sequel::Error, IOError say(error., :red) when DbAgile::SchemaSemanticsError say(error.(true), :red) when DbAgile::InternalError say("DbAgile encountered an internal error.\n Please replay with dba --backtrace and report the error!", :red) say(error., :red) when DbAgile::Error say(error., :red) when Interrupt say("Command interrupted by user", :magenta) else say("ERROR (#{error.class}): #{error.}", :red) end if show_backtrace? say(error.backtrace.join("\n")) end error end |
#show_backtrace? ⇒ Boolean
Shows the backtrace when an error occurs?
9 10 11 |
# File 'lib/dbagile/environment/on_error.rb', line 9 def show_backtrace? @show_backtrace end |