class Athena::Routing::Exceptions::HTTPException

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

Defined in:

exceptions/http_exception.cr

Constructors

Instance Method Summary

Instance methods inherited from class Exception

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

Constructor Detail

def self.new(status : HTTP::Status, message : String, cause : Exception | Nil = nil, headers : HTTP::Headers = HTTP::Headers.new) #

Instantiates self with the given status and message.

Optionally includes cause, and headers.


[View source]
def self.new(status_code : Int32, message : String, cause : Exception | Nil = nil, headers : HTTP::Headers = HTTP::Headers.new) #

Instantiates self with the given status_code and message.

Optionally includes cause, and headers.


[View source]

Instance Method Detail

def headers : HTTP::Headers #

Any HTTP response headers associated with self.

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


[View source]
def 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]
def status : HTTP::Status #

The HTTP::Status associated with self.


[View source]
def status_code : Int32 #

Returns the HTTP status code of #status.


[View source]
def to_json(builder : JSON::Builder) : Nil #

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


[View source]