module Hanami::Action::Rack::Errors
This module provides method to set exceptions to Rack
env:
* `rack.errors` - IO for errors, as requested by Rack SPEC * `rack.exception` - De-facto standard for Ruby exception tracking SaaS
@see www.rubydoc.info/github/rack/rack/file/SPEC#The_Error_Stream @see github.com/hanami/controller/issues/133
@since 1.3.3 @api private
Constants
- RACK_ERRORS
@since 1.3.3 @api private
- RACK_EXCEPTION
@since 1.3.3 @api private
Public Class Methods
_dump_exception(exception)
click to toggle source
Format exception info with name and backtrace
@param exception [Exception]
@since 1.3.3 @api private
# File lib/hanami/action/rack/errors.rb, line 47 def self._dump_exception(exception) [[exception.class, exception.message].compact.join(": "), *exception.backtrace].join("\n\t") end
set(env, exception)
click to toggle source
Set exception in Rack
env
@param env [Hash] the Rack
environment @param exception [Exception] the exception to set
@since 1.3.3 @api private
# File lib/hanami/action/rack/errors.rb, line 32 def self.set(env, exception) env[RACK_EXCEPTION] = exception return unless errors = env[RACK_ERRORS] # rubocop:disable Lint/AssignmentInCondition errors.write(_dump_exception(exception)) errors.flush end