Sha256: 62bd1088efd7b0865e6e4ea551fc6d5ce06d37a3981df73e529d01cad58af97f

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

module Frank
  module Rescue

    def render_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)
      @response.body            = Tilt::HamlTemplate.new(template).render(obj, locals = locals)

      log_request('404')
    end

    def render_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)
      @response.body            = Tilt::HamlTemplate.new(template).render(obj, locals = locals)

      log_request('500', excp)
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
frank-1.0.5 lib/frank/rescue.rb
frank-1.0.4 lib/frank/rescue.rb
frank-1.0.3 lib/frank/rescue.rb
frank-1.0.2 lib/frank/rescue.rb
frank-1.0.1 lib/frank/rescue.rb
frank-1.0.0 lib/frank/rescue.rb
frank-0.4.1 lib/frank/rescue.rb
frank-0.4.0 lib/frank/rescue.rb