Module: CommandKit::BugReport
- Extended by:
- ModuleMethods
- Includes:
- ExceptionHandler, Printing
- Defined in:
- lib/command_kit/bug_report.rb
Overview
Adds an exception handler to print a bug report when an unhandled exception
is raised by run
.
Defined Under Namespace
Modules: ClassMethods, ModuleMethods
Constant Summary
Constants included from Printing
Instance Method Summary collapse
-
#bug_report_url ⇒ String?
The bug report URL.
-
#on_exception(error) ⇒ Object
Overrides #on_exception to print a bug report for unhandled exceptions and then exit with
-1
. -
#print_bug_report(error) ⇒ Object
Prints a bug report for the unhandled exception.
Methods included from ModuleMethods
Methods included from Printing
#print_error, #print_exception
Methods included from Stdio
#abort, #gets, #initialize, #print, #printf, #putc, #puts, #readline, #readlines, #stderr, #stdin, #stdout
Methods included from ExceptionHandler
Instance Method Details
#bug_report_url ⇒ String?
The bug report URL.
73 74 75 |
# File 'lib/command_kit/bug_report.rb', line 73 def bug_report_url self.class.bug_report_url end |
#on_exception(error) ⇒ Object
Overrides #on_exception to print a bug report for unhandled exceptions
and then exit with -1
.
84 85 86 87 |
# File 'lib/command_kit/bug_report.rb', line 84 def on_exception(error) print_bug_report(error) exit(-1) end |
#print_bug_report(error) ⇒ Object
Prints a bug report for the unhandled exception.
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/command_kit/bug_report.rb', line 95 def print_bug_report(error) url = bug_report_url stderr.puts stderr.puts "Oops! Looks like you have found a bug. Please report it!" stderr.puts url if url stderr.puts stderr.puts '```' print_exception(error) stderr.puts '```' end |