Sha256: bc39ef46042fbb931e21447d0ff24f153a4de4a6473db272538723244392910d
Contents?: true
Size: 857 Bytes
Versions: 3
Compression:
Stored size: 857 Bytes
Contents
# frozen_string_literal: true Dir[File.join(__dir__, 'errors', '**', '*.rb')].each { |f| require_relative f } module Easyship # Represents a mapping of HTTP status codes to Easyship-specific classes class Error # rubocop:disable Style::MutableConstant Style::MissingElse ERRORS = { 401 => Easyship::Errors::InvalidTokenError, 402 => Easyship::Errors::PaymentRequiredError, 404 => Easyship::Errors::ResourceNotFoundError, 422 => Easyship::Errors::UnprocessableContentError, 429 => Easyship::Errors::RateLimitError } ERRORS.default_proc = proc do |_hash, key| case key.to_s when /4\d{2}/ Easyship::Errors::ClientError when /5\d{2}/ Easyship::Errors::ServerError end end # rubocop:enable Style::MutableConstant Style::MissingElse ERRORS.freeze end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
easyship-0.1.2 | lib/easyship/error.rb |
easyship-0.1.1 | lib/easyship/error.rb |
easyship-0.1.0 | lib/easyship/error.rb |