Exception: Discordrb::Errors::CodeError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Discordrb::Errors::CodeError
- Defined in:
- lib/discordrb/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)
36 37 38 39 40 |
# File 'lib/discordrb/errors.rb', line 36 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.
30 31 32 |
# File 'lib/discordrb/errors.rb', line 30 def code @code end |
Instance Attribute Details
#errors ⇒ Hash (readonly)
Returns More precise errors.
58 59 60 |
# File 'lib/discordrb/errors.rb', line 58 def errors @errors end |
#message ⇒ String (readonly)
Returns This error's represented message.
55 56 57 |
# File 'lib/discordrb/errors.rb', line 55 def @message end |
Instance Method Details
#code ⇒ Integer
Returns The error code represented by this error.
43 44 45 |
# File 'lib/discordrb/errors.rb', line 43 def code self.class.code end |
#full_message ⇒ String
Returns A message including the message and flattened errors.
48 49 50 51 52 |
# File 'lib/discordrb/errors.rb', line 48 def (*) error_list = @errors.collect { |err| "\t- #{err}" } "#{@message}\n#{error_list.join("\n")}" end |