Sha256: 4a4939abcdd46c7eb95cbfe62914217a2bf00c3f227da427cfd8a50f9518077b

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

module Frank
  module Rescue

    def render_404
      log_request('404')
      template = File.expand_path(File.dirname(__FILE__)) + '/templates/404.haml'
      locals = { :request => @env,
                 :dynamic_folder => Frank.dynamic_folder,
                 :static_folder => Frank.static_folder,
                 :environment => Frank.environment }

      @response['Content-Type'] = 'text/html'
      @response.status          = 404

      obj = Object.new.extend(TemplateHelpers)
      Tilt::HamlTemplate.new(template).render(obj, locals = locals)
    end

    def render_500(excp)
      log_request('500', excp)
      template = File.expand_path(File.dirname(__FILE__)) + '/templates/500.haml'
      locals   = { :request => @env,
                   :params => @request.params,
                   :exception => excp }

      @response['Content-Type'] = 'text/html'
      @response.status          = 500

      obj = Object.new.extend(TemplateHelpers)
      Tilt::HamlTemplate.new(template).render(obj, locals = locals)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
frank-1.0.12 lib/frank/rescue.rb
frank-1.0.11 lib/frank/rescue.rb
frank-1.0.10 lib/frank/rescue.rb
frank-1.0.9 lib/frank/rescue.rb
frank-1.0.8 lib/frank/rescue.rb
frank-1.0.7 lib/frank/rescue.rb
frank-1.0.6 lib/frank/rescue.rb