class Onyx::HTTP::Middleware::Rescuer::Standard(T)

Overview

A rescuer which logs a error colorfully into a standard ::Logger. It also logs the ::HTTP::Request#id if it's present. Should be put after Logger in the stack.

logger = Onyx::HTTP::Middleware::Logger.new
renderer = Onyx::HTTP::Middleware::Renderer.new
rescuer = Onyx::HTTP::Middleware::Rescuers::Standard(Exception).new(renderer)
router = Onyx::HTTP::Middleware::Router.new
handlers = [logger, rescuer, router, renderer]

Included Modules

Defined in:

onyx-http/middleware/rescuer/standard.cr

Constructors

Instance Method Summary

Instance methods inherited from module Onyx::HTTP::Middleware::Rescuer(T)

before_next_handler(context : HTTP::Server::Context, error : T) before_next_handler, handle(context : HTTP::Server::Context, error : T) handle, next_handler : ::HTTP::Handler next_handler, next_handler=(next_handler : ::HTTP::Handler) next_handler=

Constructor methods inherited from module Onyx::HTTP::Middleware::Rescuer(T)

new(next_handler : ::HTTP::Handler) new

Constructor Detail

def self.new(next_handler : ::HTTP::Handler? = nil, logger : ::Logger = ::Logger.new(STDERR), verbose : Bool = true) #

Set verbose to false to turn off logging errors' backtraces.


[View source]

Instance Method Detail

def handle(context, error) #

Log the error into the #logger.


[View source]
def logger : ::Logger #

A Logger to log to. Can be changed in runtime.


[View source]
def logger=(logger : ::Logger) #

A Logger to log to. Can be changed in runtime.


[View source]