Exception: Rubycord::Errors::CodeError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Rubycord::Errors::CodeError
- Defined in:
- lib/rubycord/errors.rb
Overview
Generic class for errors denoted by API error codes
Class Attribute Summary collapse
-
.code ⇒ Integer
readonly
The error code represented by this error class.
Instance Attribute Summary collapse
-
#errors ⇒ Hash
readonly
More precise errors.
-
#message ⇒ String
readonly
This error's represented message.
Instance Method Summary collapse
-
#code ⇒ Integer
The error code represented by this error.
-
#full_message ⇒ String
A message including the message and flattened errors.
-
#initialize(message, errors = nil) ⇒ CodeError
constructor
Create a new error with a particular message (the code should be defined by the class instance variable).
Constructor Details
#initialize(message, errors = nil) ⇒ CodeError
Create a new error with a particular message (the code should be defined by the class instance variable)
34 35 36 37 38 |
# File 'lib/rubycord/errors.rb', line 34 def initialize(, errors = nil) @message = @errors = errors ? flatten_errors(errors) : [] end |
Class Attribute Details
.code ⇒ Integer (readonly)
Returns The error code represented by this error class.
28 29 30 |
# File 'lib/rubycord/errors.rb', line 28 def code @code end |
Instance Attribute Details
#errors ⇒ Hash (readonly)
Returns More precise errors.
56 57 58 |
# File 'lib/rubycord/errors.rb', line 56 def errors @errors end |
#message ⇒ String (readonly)
Returns This error's represented message.
53 54 55 |
# File 'lib/rubycord/errors.rb', line 53 def @message end |
Instance Method Details
#code ⇒ Integer
Returns The error code represented by this error.
41 42 43 |
# File 'lib/rubycord/errors.rb', line 41 def code self.class.code end |
#full_message ⇒ String
Returns A message including the message and flattened errors.
46 47 48 49 50 |
# File 'lib/rubycord/errors.rb', line 46 def (*) error_list = @errors.collect { |err| "\t- #{err}" } "#{@message}\n#{error_list.join("\n")}" end |