Method: APIClientBuilder::Request#error_handlers

Defined in:
lib/api_client_builder/request.rb

#error_handlersArray<Block>

Yields the collection of error handlers that have been populated via the on_error interface. If none are defined, this will provide a default error handler that will provide context about the error and also how to define a new error handler.

Returns:

  • (Array<Block>)

    the error handlers collection



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/api_client_builder/request.rb', line 24

def error_handlers
  if error_handlers_collection.empty?
    on_error do |page, _handler|
      raise DefaultPageError, "        Default error for bad response. If you want to handle this error use #on_error\n        on the response in your api consumer. Error Code: \#{page.status_code}.\n      MESSAGE\n    end\n  end\n  error_handlers_collection\nend\n"