Class: FrederickAPI::V2::Errors::Error

Inherits:
JsonApiClient::Errors::ClientError
  • Object
show all
Defined in:
lib/frederick_api/v2/errors/errors.rb

Overview

Base exception class for client errors (i.e. validation, bad request)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ Error

Initialize with a JsonApiClient::ResultSet or a Resource



11
12
13
14
15
# File 'lib/frederick_api/v2/errors/errors.rb', line 11

def initialize(result)
  # @env is used in base class JsonApiClient::Errors::Error
  @env = result
  @errors = result.errors || []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/frederick_api/v2/errors/errors.rb', line 8

def errors
  @errors
end

Instance Method Details

#to_sObject



17
18
19
20
# File 'lib/frederick_api/v2/errors/errors.rb', line 17

def to_s
  return "Client Error: #{self.errors.first['detail']}" if self.errors.any?
  super
end