Exception: Syntropy::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Syntropy::Error
- Defined in:
- lib/syntropy/errors.rb
Overview
The base Syntropy error class
Direct Known Subclasses
Constant Summary collapse
- Status =
Qeweney::Status
- DEFAULT_STATUS =
By default, the HTTP status for errors is 500 Internal Server Error
Qeweney::Status::INTERNAL_SERVER_ERROR
Instance Attribute Summary collapse
-
#http_status ⇒ Integer, String
readonly
Returns the HTTP status for the error.
Class Method Summary collapse
-
.http_status(err) ⇒ Integer, String
Returns the HTTP status for the given exception.
-
.method_not_allowed(msg = '') ⇒ Syntropy::Error
Creates an error with status 405 Method Not Allowed.
-
.not_found(msg = '') ⇒ Syntropy::Error
Creates an error with status 404 Not Found.
-
.teapot(msg = '') ⇒ Syntropy::Error
Creates an error with status 418 I’m a teapot.
Instance Method Summary collapse
-
#initialize(http_status = DEFAULT_STATUS, msg = '') ⇒ void
constructor
Initializes a Syntropy error with the given HTTP status and message.
Constructor Details
#initialize(http_status = DEFAULT_STATUS, msg = '') ⇒ void
Initializes a Syntropy error with the given HTTP status and message.
43 44 45 46 |
# File 'lib/syntropy/errors.rb', line 43 def initialize(http_status = DEFAULT_STATUS, msg = '') super(msg) @http_status = http_status end |
Instance Attribute Details
#http_status ⇒ Integer, String (readonly)
Returns the HTTP status for the error.
51 52 53 |
# File 'lib/syntropy/errors.rb', line 51 def http_status @http_status end |
Class Method Details
.http_status(err) ⇒ Integer, String
Returns the HTTP status for the given exception
17 18 19 |
# File 'lib/syntropy/errors.rb', line 17 def self.http_status(err) err.respond_to?(:http_status) ? err.http_status : DEFAULT_STATUS end |
.method_not_allowed(msg = '') ⇒ Syntropy::Error
Creates an error with status 405 Method Not Allowed
29 |
# File 'lib/syntropy/errors.rb', line 29 def self.method_not_allowed(msg = '') = new(Status::METHOD_NOT_ALLOWED, msg) |
.not_found(msg = '') ⇒ Syntropy::Error
Creates an error with status 404 Not Found
24 |
# File 'lib/syntropy/errors.rb', line 24 def self.not_found(msg = '') = new(Status::NOT_FOUND, msg) |
.teapot(msg = '') ⇒ Syntropy::Error
Creates an error with status 418 I’m a teapot
34 |
# File 'lib/syntropy/errors.rb', line 34 def self.teapot(msg = '') = new(Status::TEAPOT, msg) |