Class: Veryfi::Error
- Inherits:
-
Object
- Object
- Veryfi::Error
- Defined in:
- lib/veryfi/error.rb
Overview
Namespace + factory for every error raised by this SDK.
All errors inherit from VeryfiError, so callers that only need to know "something went wrong with Veryfi" can keep using:
begin client.document.process(file_path: path) rescue Veryfi::Error::VeryfiError => e # … end
Callers that want to react differently per HTTP status can rescue a more specific subclass:
begin client.document.process(file_path: path) rescue Veryfi::Error::Unauthorized then refresh_credentials! rescue Veryfi::Error::TooManyRequests then back_off rescue Veryfi::Error::ServerError then schedule_retry rescue Veryfi::Error::VeryfiError then log_and_raise end
Defined Under Namespace
Classes: AccessLimitReached, BadRequest, ClientError, Conflict, NotFound, RequestTimeout, ServerError, TooManyRequests, Unauthorized, UnsupportedMediaType, VeryfiError
Class Method Summary collapse
-
.from_response(status, response) ⇒ VeryfiError
Build the right error subclass for the given HTTP status + response body.
Class Method Details
.from_response(status, response) ⇒ VeryfiError
Build the right error subclass for the given HTTP status + response body. Always returns an instance of VeryfiError or one of its subclasses; never raises.
93 94 95 96 97 98 |
# File 'lib/veryfi/error.rb', line 93 def self.from_response(status, response) klass = error_class_for(status) = (status, response) klass.new(, response, status) end |