Exception: LifenFhir::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/lifen_fhir/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, response: nil, params: {}, client: "app", token: nil) ⇒ Error

Returns a new instance of Error.



7
8
9
10
11
12
13
14
15
# File 'lib/lifen_fhir/error.rb', line 7

def initialize(message: , response: nil, params: {}, client: "app", token: nil)
  self.response = response
  self.params = params

  @client = client
  @token = token

  super(message)
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



5
6
7
# File 'lib/lifen_fhir/error.rb', line 5

def params
  @params
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/lifen_fhir/error.rb', line 5

def response
  @response
end

Instance Method Details

#contextObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lifen_fhir/error.rb', line 17

def context
  return {} if response.nil?

  {
    url: response.env.url.to_s,
    method: response.env.method.to_s,
    token: trucanted_token,
    payload_sent: filtered_params,
    trace_id: extracted_trace_id,
    payload_received: response.body,
    client: @client
  }

end

#raven_contextObject



32
33
34
35
36
# File 'lib/lifen_fhir/error.rb', line 32

def raven_context
  { :extra => {
    lifen: context
  } }
end