Sha256: a62a02c2cf4a96cf4a87d1c1d0db2928906ffee2e40db9abea02818a2f2d6644

Contents?: true

Size: 1.31 KB

Versions: 18

Compression:

Stored size: 1.31 KB

Contents

#          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

module Ramaze
  class Controller
    # The default error-page handler. you can overwrite this method
    # in your controller and create your own error-template for use.
    #
    # Error-pages can be in whatever the templating-engine of your controller
    # is set to.
    #   Ramaze::Dispatcher::Error.current
    # holds the exception thrown.

    def error
      error = Dispatcher::Error.current
      title = error.message

      unless Action.current.template
        response['Content-Type'] = 'text/plain'
        respond %(
          #{error.message}
            #{error.backtrace.join("\n            ")}

          #{PP.pp request, '', 200}
        ).ui
      end

      backtrace_size = Global.backtrace_size
      @backtrace = error.backtrace[0..20].map{|line|
        file, lineno, meth = *Ramaze.parse_backtrace(line)
        lines = Ramaze.caller_lines(file, lineno, backtrace_size)

        [ lines, lines.object_id.abs, file, lineno, meth ]
      }

      # for backwards-compat with old error.zmr
      @colors = [255] * @backtrace.size

      @title = h(title)
      @editor = ENV['EDITOR'] || 'vim'
      title
    rescue Object => ex
      Log.error(ex)
    end
  end
end

Version data entries

18 entries across 18 versions & 5 rubygems

Version Path
Pistos-ramaze-2008.09 lib/ramaze/controller/error.rb
Pistos-ramaze-2008.12 lib/ramaze/controller/error.rb
Pistos-ramaze-2009.01 lib/ramaze/controller/error.rb
Pistos-ramaze-2009.02 lib/ramaze/controller/error.rb
clivecrous-ramaze-0.3.9.5 lib/ramaze/controller/error.rb
manveru-ramaze-2008.07 lib/ramaze/controller/error.rb
manveru-ramaze-2008.08 lib/ramaze/controller/error.rb
manveru-ramaze-2008.09 lib/ramaze/controller/error.rb
manveru-ramaze-2008.10 lib/ramaze/controller/error.rb
manveru-ramaze-2008.12 lib/ramaze/controller/error.rb
manveru-ramaze-2009.01 lib/ramaze/controller/error.rb
ptomato-ramaze-2009.02.1 lib/ramaze/controller/error.rb
ptomato-ramaze-2009.02 lib/ramaze/controller/error.rb
ramaze-2008.06 lib/ramaze/controller/error.rb
ramaze-2009.01 lib/ramaze/controller/error.rb
ramaze-2008.11 lib/ramaze/controller/error.rb
ramaze-2009.03 lib/ramaze/controller/error.rb
ramaze-2009.02 lib/ramaze/controller/error.rb