Files

Ramaze::Helper::Error

The Error helper module provides methods for interrupting the current request and responding with an error message and corresponding HTTP error code.

Public Instance Methods

error() click to toggle source

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
error_400(message = nil) click to toggle source

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
error_403() click to toggle source

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
error_404() click to toggle source

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
error_405() click to toggle source

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
error_500() click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.