Module: MyApiClient::ErrorHandling

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/my_api_client/error_handling.rb,
lib/my_api_client/error_handling/generator.rb,
lib/my_api_client/error_handling/retry_option_processor.rb

Overview

Note:

You need to define ‘class_attribute: error_handler, default: []` for the included class.

Provides ‘error_handling` as DSL.

Examples:

error_handling status_code: 200, json: :forbid_nil
error_handling status_code: 400..499, raise: MyApiClient::ClientError
error_handling status_code: 500..599, raise: MyApiClient::ServerError do |params, logger|
  logger.warn 'Server error occurred.'
end

error_handling json: { '$.errors.code': 10..19 }, with: :my_error_handling
error_handling json: { '$.errors.code': 20 }, raise: MyApiClient::ApiLimitError
error_handling json: { '$.errors.message': /Sorry/ }, raise: MyApiClient::ServerError
error_handling json: { '$.errors.code': :negative? }

Defined Under Namespace

Classes: Generator, RetryOptionProcessor