Sha256: 1af28d55759c1f5433ef77c14c1fb5b2387276af27dddb148adcf50e5318b230
Contents?: true
Size: 800 Bytes
Versions: 3
Compression:
Stored size: 800 Bytes
Contents
module Nyanko module ExceptionHandler class << self def handle(exception) logger.debug Message.new(exception).to_s raise exception if Config.raise_error end def logger Rails.logger end end class Message def initialize(exception) @exception = exception end def to_s "#{prefix} #{klass}#{body}\n#{backtrace}" end def prefix " [Nyanko]" end def body unless @exception.message.empty? " - #{@exception}" end end def klass @exception.class end def backtrace lines = @exception.backtrace[0...Config.backtrace_limit] lines.map {|line| "#{prefix} #{line}" }.join("\n") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nyanko-0.0.5 | lib/nyanko/exception_handler.rb |
nyanko-0.0.4 | lib/nyanko/exception_handler.rb |
nyanko-0.0.3 | lib/nyanko/exception_handler.rb |