Class: Honeybadger::CLI::Exec Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Helpers::BackendCmd
Defined in:
lib/honeybadger/cli/exec.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

FAILED_TEMPLATE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

<<-MSG
Honeybadger detected failure or error output for the command:
`<%= args.join(' ') %>`

PROCESS ID: <%= pid %>

RESULT CODE: <%= code %>

ERROR OUTPUT:
<%= stderr %>

STANDARD OUTPUT:
<%= stdout %>
MSG
NO_EXEC_TEMPLATE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

<<-MSG
Honeybadger failed to execute the following command:
`<%= args.join(' ') %>`

The command was not executable. Try adjusting permissions on the file.
MSG
NOT_FOUND_TEMPLATE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

<<-MSG
Honeybadger failed to execute the following command:
`<%= args.join(' ') %>`

The command was not found. Make sure it exists in your PATH.
MSG

Instance Method Summary collapse

Methods included from Helpers::BackendCmd

#error_message

Constructor Details

#initialize(options, args, config) ⇒ Exec

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Exec.



46
47
48
49
50
51
# File 'lib/honeybadger/cli/exec.rb', line 46

def initialize(options, args, config)
  @options = options
  @args = args
  @config = config
  @shell = ::Thor::Base.shell.new
end

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/honeybadger/cli/exec.rb', line 53

def run
  result = exec_cmd
  return if result.success

  executable = args.first.to_s[/\S+/]
  payload = {
    api_key: config.get(:api_key),
    notifier: NOTIFIER,
    error: {
      class: 'honeybadger exec error',
      message: result.msg
    },
    request: {
      component: executable,
      context: {
        command: args.join(' '),
        code: result.code,
        pid: result.pid,
        pwd: Dir.pwd,
        path: ENV['PATH']
      }
    },
    server: {
      project_root: Dir.pwd,
      environment_name: config.get(:env),
      time: Time.now,
      stats: Util::Stats.all
    }
  }

  begin
    response = config.backend.notify(:notices, payload)
  rescue
    say(result.msg)
    raise
  end

  if !response.success?
    say(result.msg)
    say(error_message(response), :red)
    exit(1)
  end

  unless quiet?
    say(result.msg)
    say("\nSuccessfully notified Honeybadger")
  end

  exit(0)
end