class Athena::Routing::Exceptions::HTTPException
- Athena::Routing::Exceptions::HTTPException
- Exception
- Reference
- Object
Overview
Represents an HTTP error.
Each child represents a specific HTTP error with the associated status code. Also optionally allows adding headers to the resulting response.
Can be used directly/inherited from to represent non-typical HTTP errors/codes.
Direct Known Subclasses
- Athena::Routing::Exceptions::BadGateway
- Athena::Routing::Exceptions::BadRequest
- Athena::Routing::Exceptions::Conflict
- Athena::Routing::Exceptions::Forbidden
- Athena::Routing::Exceptions::Gone
- Athena::Routing::Exceptions::LengthRequired
- Athena::Routing::Exceptions::MethodNotAllowed
- Athena::Routing::Exceptions::NotAcceptable
- Athena::Routing::Exceptions::NotFound
- Athena::Routing::Exceptions::NotImplemented
- Athena::Routing::Exceptions::PreconditionFailed
- Athena::Routing::Exceptions::ServiceUnavailable
- Athena::Routing::Exceptions::TooManyRequests
- Athena::Routing::Exceptions::Unauthorized
- Athena::Routing::Exceptions::UnprocessableEntity
- Athena::Routing::Exceptions::UnsupportedMediaType
Defined in:
exceptions/http_exception.crConstructors
-
.new(status : HTTP::Status, message : String, cause : Exception | Nil = nil, headers : HTTP::Headers = HTTP::Headers.new)
Instantiates
selfwith the given status and message. -
.new(status_code : Int32, message : String, cause : Exception | Nil = nil, headers : HTTP::Headers = HTTP::Headers.new)
Instantiates
selfwith the given status_code and message.
Instance Method Summary
-
#headers : HTTP::Headers
Any HTTP response headers associated with
self. -
#headers=(headers : HTTP::Headers)
Any HTTP response headers associated with
self. -
#status : HTTP::Status
The
HTTP::Statusassociated withself. -
#status_code : Int32
Returns the HTTP status code of
#status. -
#to_json(builder : JSON::Builder) : Nil
Serializes
selfto JSON in the format of{"code":400,"message":"Exception message"}
Instance methods inherited from class Exception
to_json(builder : JSON::Builder) : Nil
to_json
Constructor Detail
Instantiates self with the given status and message.
Optionally includes cause, and headers.
Instantiates self with the given status_code and message.
Optionally includes cause, and headers.
Instance Method Detail
Any HTTP response headers associated with self.
Some HTTP errors use response headers to give additional information about self.
Any HTTP response headers associated with self.
Some HTTP errors use response headers to give additional information about self.
Serializes self to JSON in the format of {"code":400,"message":"Exception message"}