Module: PlatformSdk::Identity::ErrorHandleable
- Included in:
- AuthClient, Client
- Defined in:
- lib/platform_sdk/identity/error_handleable.rb
Overview
Error handling for Identity SDK
Instance Method Summary collapse
Instance Method Details
#raise_error_with_payload(exception_class, error) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/platform_sdk/identity/error_handleable.rb', line 17 def raise_error_with_payload(exception_class, error) json_log = { exception: exception_class.new.class.name.demodulize, payload: error.response.dig(:request, :body), response_body: error.response[:body], status: error.response[:status] }.compact Rails.logger.info json_log.to_json if defined?(Rails) raise exception_class, error.response end |
#with_rescue ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/platform_sdk/identity/error_handleable.rb', line 7 def with_rescue yield rescue Faraday::TimeoutError => e raise TimeoutError, e rescue Faraday::ServerError => e raise_error_with_payload(ServerError, e) rescue Faraday::ClientError => e raise_error_with_payload(ClientError, e) end |