RoRvsWild

Error tracking

By default, RoRvsWild catches exceptions raised by requests and jobs.

Configuration

Send errors manually

From a begin / rescue block:

begin
  # Your code ...
rescue => exception
  RorVsWild.record_error(exception)
end

Or:

RorVsWild.catch_error { 1 / 0 }  # => #<ZeroDivisionError: divided by 0>
Add extra details
RorVsWild.record_error(exception, {something: "important"})
RorVsWild.catch_error(something: "important") { 1 / 0 }

Pre-fill context

It is also possible to pre-fill this context data at the begining of each request or job:

class ApplicationController < ActionController::Base
  before_action :prefill_error_context
  def prefill_error_context
    RorVsWild.merge_error_context(something: "important")
  end
end

Rails error reporter

Is a common interface to report errors without coupling your code to a specific service. You must have at least the agent version 1.10.0. Here is an example:

Rails.error.handle { 1 / 0 } # Same as RorVsWild.catch_error { 1 / 0 }

begin
  1 / 0
rescue => e
  Rails.error.report(e) # Same as RorVsWild.record_error(e)
end

Ignore specific exceptions

Use the ignore_exceptions parameter:

# config/rorvswild.yml
production:
  api_key: "API_KEY"
  ignore_exceptions:
    - ActionController::RoutingError
    - ZeroDivisionError

Or with an initializer:

# config/initializers/rorvswild.rb
RorVsWild::Client.new(
  api_key: "API_KEY",
  ignore_exceptions: ["ActionController::RoutingError", "ZeroDivisionError"]
)

By default all exceptions returned by ActionDispatch::ExceptionWrapper.rescue_responses are ignored, because they are already handled by Rails. Thus you receive less noise and can focus on real errors only. However, if you would like to see all errors, such as HTTP malformed request, you have to explicitely set ignore_exceptions as an empty array:

# config/rorvswild.yml
production:
  api_key: "API_KEY"
  ignore_exceptions: []
# config/initializers/rorvswild.rb
RorVsWild::Client.new(api_key: "API_KEY", ignore_exceptions: [])

Here is a list of default ignored the exceptions that may vary depending on the version of Rails:

  • AbstractController::ActionNotFound
  • ActionController::BadRequest
  • ActionController::InvalidAuthenticityToken
  • ActionController::InvalidCrossOriginRequest
  • ActionController::MethodNotAllowed
  • ActionController::MissingExactTemplate
  • ActionController::NotImplemented
  • ActionController::ParameterMissing
  • ActionController::RoutingError
  • ActionController::UnknownFormat
  • ActionController::UnknownHttpMethod
  • ActionDispatch::Http::MimeNegotiation::InvalidType
  • ActionDispatch::Http::Parameters::ParseError
  • ActiveRecord::RecordInvalid
  • ActiveRecord::RecordNotFound
  • ActiveRecord::RecordNotSaved
  • ActiveRecord::StaleObjectError
  • Rack::QueryParser::InvalidParameterError
  • Rack::QueryParser::ParameterTypeError

Need help?

Contact us.

RoRvsWild monitors your Ruby on Rails applications.

Try for free
RoRvsWild Ruby Request group