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.

Since:

  • 0.4.0

Defined Under Namespace

Modules: ClassMethods, ModuleMethods

Constant Summary

Constants included from Printing

Printing::EOL

Instance Method Summary collapse

Methods included from ModuleMethods

included

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

#main

Instance Method Details

#bug_report_urlString?

The bug report URL.

Returns:

  • (String, nil)

Since:

  • 0.4.0



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.

Parameters:

  • error (Exception)

    The unhandled exception.

Since:

  • 0.4.0



84
85
86
87
# File 'lib/command_kit/bug_report.rb', line 84

def on_exception(error)
  print_bug_report(error)
  exit(-1)
end

Prints a bug report for the unhandled exception.

Parameters:

  • error (Exception)

    The unhandled exception.

Since:

  • 0.4.0



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