Sha256: 34f54c4563de0daf53d2d51cd9aea3219aeb39044db4b351c796329f50966dc0
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com # All files in this distribution are subject to the terms of the Ruby license. module Ramaze module Dispatcher class Error HANDLE_ERROR = { Exception => [ 500, '/error' ], Ramaze::Error::NoAction => [ 404, '/error' ], Ramaze::Error::NoController => [ 404, '/error' ], } class << self trait :last_error => nil def process error log_error(error) Thread.current[:exception] = error key = error.class.ancestors.find{|a| HANDLE_ERROR[a]} status, path = *HANDLE_ERROR[key || Exception] unless error.message =~ %r(`#{path.split('/').last}') Response.current.status = status return Dispatcher.dispatch_to(path) if path and Global.error_page end Dispatcher.build_response(error.message, status) rescue Object => ex Inform.error(ex) Dispatcher.build_response(ex.message, status || 500) end def log_error error error_message = error.message if trait[:last_error] == error_message Inform.error(error_message) else trait[:last_error] = error_message Inform.error(error) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ramaze-0.1.2 | lib/ramaze/dispatcher/error.rb |