Sha256: e0d3038ba48817895cf64ff371c5682155a8eb9eaeef719c1af88d73f43cfb73
Contents?: true
Size: 1.11 KB
Versions: 27
Compression:
Stored size: 1.11 KB
Contents
# encoding: utf-8 module Sinatra module ErrorHandler extend Hexacta def enable_errors p "Enabling errors..." ErrorHandler.setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/errors") error_template(404) error_template(403) error_template(500) error_template(Sequel::DatabaseDisconnectError) error_template(Sequel::DatabaseConnectionError) end def error_template(code) if code.is_a? Numeric template_code = code else template_code = code.to_s.split('::').last end ErrorHandler.copy_file("/lib/sinatra/views/errors/#{template_code}.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/errors/#{template_code}.slim") error code do if code == 500 title = env['sinatra.error'].message message = (["in #{request.url}"] + env['sinatra.error'].backtrace).join(','); NotificationSender.instance.send_error(authenticated(User),title,message) end slim "#{Hexacta::GEM_FILE_DIR}/errors/#{template_code}".to_sym, locals: { :params => params } end end end register ErrorHandler end
Version data entries
27 entries across 27 versions & 1 rubygems