Method: Unit::UnitErrorPayload.from_json_api

Defined in:
lib/unit/errors/unit_error_payload.rb

.from_json_api(error) ⇒ UnitErrorPayload

Creates a new UnitErrorPayload from given response error.

Parameters:

  • error (Hash)

    One of the errors returned in a response from Unit’s API

Returns:

  • (UnitErrorPayload)

    a new UnitErrorPayload populated with values taken from the response error



26
27
28
29
30
31
32
33
34
35
# File 'lib/unit/errors/unit_error_payload.rb', line 26

def self.from_json_api(error)
  new(
    error["title"],
    error["status"],
    error["detail"],
    error["details"],
    error["source"],
    error["code"]
  )
end