Exception: ActionKitRest::Response::ValidationError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/action_kit_rest/response/validation_error.rb

Direct Known Subclasses

InvalidAkidError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ ValidationError

Returns a new instance of ValidationError.



8
9
10
11
12
13
# File 'lib/action_kit_rest/response/validation_error.rb', line 8

def initialize(params)
  self.url = params[:url]
  self.body = params[:body].dup
  self.errors = JSON.parse(params[:body])['errors']
  super()
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



6
7
8
# File 'lib/action_kit_rest/response/validation_error.rb', line 6

def body
  @body
end

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/action_kit_rest/response/validation_error.rb', line 6

def errors
  @errors
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/action_kit_rest/response/validation_error.rb', line 6

def url
  @url
end

Instance Method Details

#to_sObject



15
16
17
18
19
20
21
22
# File 'lib/action_kit_rest/response/validation_error.rb', line 15

def to_s
  "#{super()} \n url: #{url} \n body: #{body.force_encoding('UTF-8')} \n errors: #{errors}"
rescue Encoding::CompatibilityError
  # Something went gravely wrong trying to construct the error message, so give up on the extra info
  # and just raise the name of the exception.
  # This will let us at least raise with a backtrace.
  super
end