Sha256: 927b241f5d7adc720429710260c5d2c4770b37a17922cd017072370f61fe0f91
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
module RightApi class ApiError < RuntimeError # Create a new ApiError. This accepts a parameter glob because this type is aliased to # a removed exception type that took only one initializer argument: the response object. # This type prefers two arguments: the request and response objects. If you pass only one # argument, it is taken to be the response. def initialize(*args) case args.size when 1 # Compatible with RightApi::Exceptions::ApiException (from 1.5.9 of the gem) @request, @response = nil, args[0] when 2 # Normal/preferred format @request, @response = args[0], args[1] else raise ArgumentError, "wrong number of arguments (#{args.size} for 1 or 2)" end super( prefix + "HTTP Code: #{@response.code.to_s}, " + "Response body: #{@response.body}") end def prefix 'Error: ' end # Get the HTTP response code that triggered this error. # # @return [Integer] the response code # def response_code @response.code end end class UnknownRouteError < ApiError def prefix 'Unknown action or route. ' end end class EmptyBodyError < ApiError def prefix 'Empty response body: ' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
right_api_client-1.6.4 | lib/right_api_client/errors.rb |
right_api_client-1.6.3 | lib/right_api_client/errors.rb |
right_api_client-1.6.2 | lib/right_api_client/errors.rb |