Sha256: e0653d325cd0559a8b435a1cace6063de73d6720940e1bfb0f818775edfa43c8

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

# encoding: utf-8
module Sinatra
  module ErrorHandler
    extend Hexacta

    def error_template(code)
      ErrorHandler.symlink("/lib/sinatra/views/errors/#{code}.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/errors/#{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(',');
          notify_error(authenticated(User),title,message)
        end
        slim "#{Hexacta::GEM_FILE_DIR}/errors/#{code}".to_sym, locals: { :params => params }
      end
    end

    p "Setting up errors directory..."
    setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/errors")
  end

  register ErrorHandler
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sinatra-hexacta-0.0.2 lib/sinatra/handlers/errors.rb
sinatra-hexacta-0.0.1 lib/sinatra/handlers/errors.rb