Sha256: adb4c0531c3496f45eef36b7350803212ff0653a08efb53b2a6992b202d4537a
Contents?: true
Size: 1.13 KB
Versions: 63
Compression:
Stored size: 1.13 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.split(':')[0].gsub('#<',''); 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
63 entries across 63 versions & 1 rubygems