Exception: Cog::Errors::CogError

Inherits:
Exception
  • Object
show all
Defined in:
lib/cog/errors.rb

Overview

Root type for all cog errors

Instance Method Summary collapse

Constructor Details

#initialize(details = {}) ⇒ CogError

Returns a new instance of CogError.



7
8
9
10
11
12
13
14
15
# File 'lib/cog/errors.rb', line 7

def initialize(details={})
  @details = if details.is_a? Hash
    details.to_a.collect do |key, value|
      "#{key} => #{value.inspect}"
    end.sort
  else
    [details]
  end
end

Instance Method Details

#messageObject



17
18
19
20
21
# File 'lib/cog/errors.rb', line 17

def message
  w = custom_message || self.class.name.underscore.split('/').last.gsub('_', ' ')
  w += " (#{@details.join ', '})" unless @details.empty?
  w
end