Sha256: d4250a109ab695abc0efbebf12c2f9f9c3903b07c0cd00c771d39c20eba6bd31
Contents?: true
Size: 1.42 KB
Versions: 5
Compression:
Stored size: 1.42 KB
Contents
require 'faraday' module Taric module FaradayMiddleware class Unauthorized < StandardError; end class BadRequest < StandardError; end class RateLimitExceeded < StandardError; end class InternalServerError < StandardError; end class ServiceUnavailable < StandardError; end class GatewayTimeout < StandardError; end class Forbidden < StandardError; end class NotFound < StandardError; end class HttpException < Faraday::Response::Middleware def call(env) @app.call(env).on_complete do |response| case response[:status] when 400 raise Taric::FaradayMiddleware::BadRequest, 'Bad parameter, check API documentation' when 401 raise Taric::FaradayMiddleware::Unauthorized, 'Check API key' when 403 raise Taric::FaradayMiddleware::Forbidden, 'Forbidden' when 404 raise Taric::FaradayMiddleware::NotFound, 'Data not found' when 429 raise Taric::FaradayMiddleware::RateLimitExceeded, 'Rate limit exceeded' when 500 raise Taric::FaradayMiddleware::InternalServerError, 'Internal server error' when 503 raise Taric::FaradayMiddleware::ServiceUnavailable, 'Service unavailable' when 504 raise Taric::FaradayMiddleware::GatewayTimeout, 'Gateway timeout' end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems