lib/lifen/user_authenticated_client.rb in lifen-0.1.4 vs lib/lifen/user_authenticated_client.rb in lifen-0.1.5
- old
+ new
@@ -15,9 +15,16 @@
req.headers['Content-Type'] = "application/json"
req.body = JSON.generate(params)
end
+ if response.status == 500
+ json = JSON.parse response.body
+
+ trace_id = json.fetch("X-B3-TraceId", "unknown")
+ raise Error, "Error 500, Internal server error (trace ID: #{trace_id})"
+ end
+
raise UnauthorizedError, "Token is not valid" if response.status == 401
raise Error, "Action is forbidden" if response.status == 403
raise InvalidParamsError, "Invalid params" if response.status == 400
json = JSON.parse response.body
\ No newline at end of file