Exception: Tap::Server::ServerError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Tap::Server::ServerError
- Defined in:
- lib/tap/server/server_error.rb
Overview
A special type of error used for specifiying controller errors.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
The error response body.
-
#headers ⇒ Object
readonly
Headers for the error response.
-
#status ⇒ Object
readonly
The error status.
Class Method Summary collapse
-
.response(err) ⇒ Object
A helper to format a non-ServerError into a ServerError response.
Instance Method Summary collapse
-
#initialize(body = "500 Server Error", status = 500, headers = {'Content-Type' => 'text/plain'}) ⇒ ServerError
constructor
A new instance of ServerError.
-
#response ⇒ Object
Formats self as a rack response array (ie [status, headers, body]).
Constructor Details
#initialize(body = "500 Server Error", status = 500, headers = {'Content-Type' => 'text/plain'}) ⇒ ServerError
Returns a new instance of ServerError.
22 23 24 25 26 27 |
# File 'lib/tap/server/server_error.rb', line 22 def initialize(body="500 Server Error", status=500, headers={'Content-Type' => 'text/plain'}) @body = body @status = status @headers = headers super(body) end |
Instance Attribute Details
#body ⇒ Object (readonly)
The error response body
20 21 22 |
# File 'lib/tap/server/server_error.rb', line 20 def body @body end |
#headers ⇒ Object (readonly)
Headers for the error response
17 18 19 |
# File 'lib/tap/server/server_error.rb', line 17 def headers @headers end |
#status ⇒ Object (readonly)
The error status
14 15 16 |
# File 'lib/tap/server/server_error.rb', line 14 def status @status end |
Class Method Details
.response(err) ⇒ Object
A helper to format a non-ServerError into a ServerError response.
8 9 10 |
# File 'lib/tap/server/server_error.rb', line 8 def response(err) new("500 #{err.class}: #{err.}\n#{err.backtrace.join("\n")}").response end |
Instance Method Details
#response ⇒ Object
Formats self as a rack response array (ie [status, headers, body]).
30 31 32 |
# File 'lib/tap/server/server_error.rb', line 30 def response [status, headers, [body]] end |