Exception: Taxjar::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Taxjar::Error
- Defined in:
- lib/taxjar/error.rb
Constant Summary collapse
- ClientError =
Class.new(self)
- ServerError =
Class.new(self)
- BadRequest =
Raised when Taxjar endpoint returns the HTTP status code 400
Class.new(ClientError)
Class.new(ClientError)
- Forbidden =
Raised when Taxjar endpoint returns the HTTP status code 403
Class.new(ClientError)
- NotFound =
Raised when Taxjar endpoint returns the HTTP status code 404
Class.new(ClientError)
- MethodNotAllowed =
Raised when Taxjar endpoint returns the HTTP status code 405
Class.new(ClientError)
- NotAcceptable =
Raised when Taxjar endpoint returns the HTTP status code 406
Class.new(ClientError)
- Gone =
Raised when Taxjar endpoint returns the HTTP status code 410
Class.new(ClientError)
- UnprocessableEntity =
Raised when Taxjar endpoint returns the HTTP status code 422
Class.new(ClientError)
- TooManyRequests =
Raised when Taxjar endpoint returns the HTTP status code 429
Class.new(ClientError)
- InternalServerError =
Raised when Taxjar endpoint returns the HTTP status code 500
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Raised when Taxjar endpoint returns the HTTP status code 504
Class.new(ServerError)
- ERRORS =
{ 400 => Taxjar::Error::BadRequest, 401 => Taxjar::Error::Unauthorized, 403 => Taxjar::Error::Forbidden, 404 => Taxjar::Error::NotFound, 405 => Taxjar::Error::MethodNotAllowed, 406 => Taxjar::Error::NotAcceptable, 410 => Taxjar::Error::Gone, 422 => Taxjar::Error::UnprocessableEntity, 429 => Taxjar::Error::TooManyRequests, 500 => Taxjar::Error::InternalServerError, 503 => Taxjar::Error::ServiceUnavailable, 504 => Taxjar::Error::GatewayTimeout }
- ConfigurationError =
Class.new(::ArgumentError)
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
- .for_json_parse_error(code) ⇒ Object
- .from_response(body) ⇒ Object
- .from_response_code(code) ⇒ Object
Instance Method Summary collapse
-
#initialize(message = '', code = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message = '', code = nil) ⇒ Error
Returns a new instance of Error.
79 80 81 82 |
# File 'lib/taxjar/error.rb', line 79 def initialize( = '', code = nil) super() @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/taxjar/error.rb', line 3 def code @code end |
Class Method Details
.for_json_parse_error(code) ⇒ Object
73 74 75 |
# File 'lib/taxjar/error.rb', line 73 def for_json_parse_error(code) ServerError.new("Couldn't parse response as JSON.", code) end |
.from_response(body) ⇒ Object
62 63 64 65 66 |
# File 'lib/taxjar/error.rb', line 62 def from_response(body) code = body[:status] = body[:detail] new(, code) end |
.from_response_code(code) ⇒ Object
68 69 70 71 |
# File 'lib/taxjar/error.rb', line 68 def from_response_code(code) = HTTP::Response::Status::REASONS[code] || "Unknown Error" new(, code) end |