Sha256: 6225bffa537bb33ea3525bd7b93a2491c926e1e4328b147d97a116dd40dae2fe
Contents?: true
Size: 970 Bytes
Versions: 2
Compression:
Stored size: 970 Bytes
Contents
module Recurly module Errors class APIError < StandardError # @!attribute recurly_error # @return [Recurly::Resources::Error] The {Recurly::Resources::Error} object attr_reader :recurly_error # Looks up an Error class by name # @example # Errors.error_class('BadRequestError') # #=> Errors::BadRequestError # @param error_key [String] # @return [Errors::APIError,Errors::NetworkError] def self.error_class(error_key) class_name = error_key.split('_').map(&:capitalize).join class_name += "Error" unless class_name.end_with?("Error") Errors.const_get(class_name) end def initialize(response, error) super(error.message) @response = response @recurly_error = error end def status_code @response.status end end end require_relative "./errors/api_errors" require_relative "./errors/network_errors" end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
recurly-3.0.0.beta.4 | lib/recurly/errors.rb |
recurly-3.0.0.beta.3 | lib/recurly/errors.rb |