Exception: RightApi::ApiError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- RightApi::ApiError
- Defined in:
- lib/right_api_client/errors.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(*args) ⇒ ApiError
constructor
Create a new ApiError.
- #prefix ⇒ Object
-
#response_code ⇒ Integer
Get the HTTP response code that triggered this error.
Constructor Details
#initialize(*args) ⇒ ApiError
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.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/right_api_client/errors.rb', line 9 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 |
Instance Method Details
#prefix ⇒ Object
27 28 29 30 |
# File 'lib/right_api_client/errors.rb', line 27 def prefix 'Error: ' end |
#response_code ⇒ Integer
Get the HTTP response code that triggered this error.
36 37 38 |
# File 'lib/right_api_client/errors.rb', line 36 def response_code @response.code end |