No commit activity in last 3 years
No release in over 3 years
Configure error handling hooks for Liquid.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 5.0
 Project Readme

LiquidErrorHandler

Configure error handling hooks for the Liquid templating language for Ruby.

Installation

Add this line to your application's Gemfile:

gem 'liquid_error_handler', '~> 0.1.0'

Usage

Register an error handler, for example in a Rails initializer. Error handlers should be callable and will receive the error as an argument.

# config/initializers/liquid_error_handler.rb

LiquidErrorHandler.register_handler do |error|
  Rails.logger.error("Liquid Error: #{error} #{error.backtrace}")
end

Use with libraries like Airbrake to send all Liquid errors to your error aggregation platform:

# config/initializers/liquid_error_handler.rb

LiquidErrorHandler.register_handler do |error|
  Airbrake.notify(error) unless Rails.env.development? || Rails.env.test?
end

Disabling

LiquidErrorHandler can be disabled by setting the environment variable LIQUID_ERROR_HANDLER_DISABLE to any value:

LIQUID_ERROR_HANDLER_DISABLE=1 rails server

Resetting

All error handlers can be removed by calling LiquidErrorHandler.reset:

LiquidErrorHandler.reset

License

MIT License