my_api_client icon indicating copy to clipboard operation
my_api_client copied to clipboard

Add `only` and `except` options to `#error_handling`

Open ryz310 opened this issue 4 years ago • 0 comments

class SomeApiClient < MyApiClient::Base
  endpoint 'https://example.com'

  error_handling status_code: 400, raise: Errors::BadRequest, except: :create_resource
  error_handling status_code: 404, raise: Errors::NotFound, only: :get_resource

  def get_resource
    get 'path/to/resource'
  end

  def create_resource(body)
    post 'path/to/resource', body: body
  end
end

ryz310 avatar Jul 02 '20 17:07 ryz310