Class: Aptible::Resource::Errors

Inherits:
Object
  • Object
show all
Defined in:
lib/aptible/resource/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#full_messagesObject

Returns the value of attribute full_messages.



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

def full_messages
  @full_messages
end

#messagesObject

Returns the value of attribute messages.



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

def messages
  @messages
end

#status_codeObject

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

Class Method Details

.from_exception(exception) ⇒ Object



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

def self.from_exception(exception)
  new.tap do |errors|
    response_json = JSON.parse(exception.response.body)
    errors.messages = { base: response_json['message'] }
    errors.full_messages = [response_json['message']]
    errors.status_code = exception.response.status
  end
end

Instance Method Details

#any?Boolean

Returns:



23
24
25
# File 'lib/aptible/resource/errors.rb', line 23

def any?
  full_messages.any?
end