Module: Onsi::ErrorResponderBase

Extended by:
ActiveSupport::Concern
Defined in:
lib/onsi/error_responder.rb

Overview

Handles default errors without StandardError

Error handled by default:

Examples:

class PeopleController < ApplicationController
  include Onsi::Controller
  include Onsi::ErrorResponderBase

  # ...
end

Author:

  • Maddie Schipper

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#notify_unhandled_exception(exception) ⇒ Object

Can be overriden to report an un-handled exception to your error service of choice.

Examples:

class ApplicationController < ActionController::API
  include Onsi::ErrorResponderBase
  include Onsi::Controller

  def notify_unhandled_exception(exception)
    Bugsnag.notify(exception)
  end

  # ...
end

Parameters:

  • exception (StandardError)

    The error to report.

Since:

  • 1.0.0



64
65
66
# File 'lib/onsi/error_responder.rb', line 64

def notify_unhandled_exception(exception)
  Rails.logger.error "Unhandled Exception `#{exception.class.name}: #{exception.message}`"
end

#render_error(response) ⇒ Object

Render an API error response.

Parameters:

Since:

  • 1.0.0



43
44
45
# File 'lib/onsi/error_responder.rb', line 43

def render_error(response)
  render(response.renderable)
end