Skip to content

class Athena::Routing::Exceptions::HTTPException
inherits Exception #

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

Class methods#

.new(status : HTTP::Status, message : String, cause : Exception? = nil, headers : HTTP::Headers = HTTP::Headers.new) #

Instantiates self with the given status and message.

Optionally includes cause, and headers.

View source

.new(status_code : Int32, message : String, cause : Exception? = nil, headers : HTTP::Headers = HTTP::Headers.new) #

Instantiates self with the given status_code and message.

Optionally includes cause, and headers.

View source

Methods#

#headers : HTTP::Headers #

Any HTTP response headers associated with self.

Some HTTP errors use response headers to give additional information about self.

View source

#headers=(headers : HTTP::Headers) #

Any HTTP response headers associated with self.

Some HTTP errors use response headers to give additional information about self.

View source

#status : HTTP::Status #

The HTTP::Status associated with self.

View source

#status_code : Int32 #

Returns the HTTP status code of #status.

View source

#to_json(builder : JSON::Builder) : Nil #

Serializes self to JSON in the format of {"code":400,"message":"Exception message"}

View source