Module: SlackMsgr::ErrorHandling

Defined in:
lib/utils/error_handling.rb

Overview

Handles all chat functionality and methods corresponding with Slack API

Class Method Summary collapse

Class Method Details

.configuration_error(_opts) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/utils/error_handling.rb', line 21

def configuration_error(_opts)
  {
    exception: ConfigurationError,
    message: "Error with configruation: access_tokens not found\n" \
      'At least one oauth token must be configured using access_tokens'
  }
end

.raise(error_type, opts = {}) ⇒ Object



7
8
9
10
11
# File 'lib/utils/error_handling.rb', line 7

def raise(error_type, opts = {})
  err = send(error_type, opts)

  Kernel.raise err[:exception], err[:message]
end

.req_args_missing(opts) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/utils/error_handling.rb', line 29

def req_args_missing(opts)
  {
    exception: ArgumentError,
    message: "Required arguments missing: Method #{opts[:method]} requires arguments:\n" \
      "[ #{opts[:req_args].join(', ')} ] Refer to https://api.slack.com/methods/"
  }
end

.unknown_method(opts) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/utils/error_handling.rb', line 13

def unknown_method(opts)
  {
    exception: NoMethodError,
    message: "Method not found: #{opts[:method] || 'unknown_method'} does not exist\n" \
      "If you would like this method added, please add an issue at #{GITHUB_REPO}"
  }
end