The Error helper module provides methods for interrupting the current request and responding with an error message and corresponding HTTP error code.
Displays an error backtrace.
# File lib/thoth/helper/error.rb, line 38 def error Session.current.drop! if Session.current error_500 unless Thoth.trait[:mode] == :devel response['Content-Type'] = 'text/html' Ramaze::Action.current.template ||= Thoth::VIEW_DIR/'error.rhtml' super end
Displays a "400 Bad Request" error message and returns a 400 response code.
# File lib/thoth/helper/error.rb, line 49 def error_400(message = nil) Session.current.drop! if Session.current if message error_layout 400, '400 Bad Request', %[ <p> Your browser sent a request that this server could not understand. </p> <p> #{message} </p> ] else error_layout 400, '400 Bad Request', %[ <p> Your browser sent a request that this server could not understand. </p> ] end end
Displays a "403 Forbidden" error message and returns a 403 response code.
# File lib/thoth/helper/error.rb, line 72 def error_403 Session.current.drop! if Session.current error_layout 403, '403 Forbidden', %[ <p> You don't have permission to access <code>#{h(request.REQUEST_URI)}</code> on this server. </p> ] end
Displays a "404 Not Found" error message and returns a 404 response code.
# File lib/thoth/helper/error.rb, line 84 def error_404 Session.current.drop! if Session.current error_layout 404, '404 Not Found', %[ <p> The requested URL <code>#{h(request.REQUEST_URI)}</code> was not found on this server. </p> ] end
Displays a "405 Method Not Allowed" error message and returns a 405 response code.
# File lib/thoth/helper/error.rb, line 97 def error_405 Session.current.drop! if Session.current error_layout 405, '405 Method Not Allowed', %[ <p> The #{request.env['REQUEST_METHOD']} method is not allowed for the requested URL. </p> ] end
Displays a "500 Internal Server Error" error message and returns a 500 response code.
# File lib/thoth/helper/error.rb, line 110 def error_500 Session.current.drop! if Session.current error_layout 500, '500 Internal Server Error', %[ <p> The server encountered an internal error and was unable to complete your request. </p> ] end
Generated with the Darkfish Rdoc Generator 2.