Exception: Digitalocean::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/digitalocean/errors.rb

Overview

Base Error

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ Error

Returns a new instance of Error.



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

def initialize(data=nil)
  @message = case data
  when Hash
    @code    = data[:code]
    data[:message]
  else
    data
  end
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



4
5
6
# File 'lib/digitalocean/errors.rb', line 4

def code
  @code
end

Instance Method Details

#messageObject



16
17
18
# File 'lib/digitalocean/errors.rb', line 16

def message
  code ? "(#{code}) #{@message}" : @message
end

#to_sObject



20
21
22
# File 'lib/digitalocean/errors.rb', line 20

def to_s
  message
end