Sha256: 8141858c7b7bb2b1bfaef2346c4852cb39ba3cb755407a3f1c75ed69c8c7c969
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true module Veryfi class Error def self.from_response(status, response) if response.empty? VeryfiError.new(format("%<code>d", code: status)) else get_error(status, response) end end def self.get_error(status, response) case status when 400 then BadRequest when 401 then UnauthorizedAccessToken when 404 then ResourceNotFound when 405 then UnexpectedHTTPMethod when 409 then AccessLimitReached when 500 then InternalError else VeryfiError.new(format("%<code>d, %<message>s", code: status, message: response["error"])) end end class BadRequest < StandardError def to_s "400, Bad Request" end end class UnauthorizedAccessToken < StandardError def to_s "401, Unauthorized Access Token" end end class ResourceNotFound < StandardError def to_s "404, Resource not found" end end class UnexpectedHTTPMethod < StandardError def to_s "405, Unexpected HTTP Method" end end class AccessLimitReached < StandardError def to_s "409, Access Limit Reached" end end class InternalError < StandardError def to_s "500, Internal Server Error" end end class VeryfiError < StandardError end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
veryfi-1.0.4 | lib/veryfi/error.rb |
veryfi-1.0.1 | lib/veryfi/error.rb |