Charyf/charyf-core

View on GitHub
lib/charyf/utils/error_handler.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Charyf
  module ErrorHandlers

    extend self

    def<<(handler)
      handlers << handler
    end

    def handle_exception(e)
      Charyf.logger.error "#{e.class}: #{e}".red
      Charyf.logger.error "\n\tBacktrace: #{e.backtrace.join("\n\t")}"

      handlers.map { |h| h.handle_exception(e) }

      e
    end

    private

    def handlers
      @handles ||= []
    end

  end
end