class Athena::HTTPKernel::Exception::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.
Included modules
Athena::HTTPKernel::Exception
Direct known subclasses
Athena::HTTPKernel::Exception::BadGateway
Athena::HTTPKernel::Exception::BadRequest
Athena::HTTPKernel::Exception::Conflict
Athena::HTTPKernel::Exception::Forbidden
Athena::HTTPKernel::Exception::Gone
Athena::HTTPKernel::Exception::LengthRequired
Athena::HTTPKernel::Exception::MethodNotAllowed
Athena::HTTPKernel::Exception::NotAcceptable
Athena::HTTPKernel::Exception::NotFound
Athena::HTTPKernel::Exception::NotImplemented
Athena::HTTPKernel::Exception::PreconditionFailed
Athena::HTTPKernel::Exception::ServiceUnavailable
Athena::HTTPKernel::Exception::TooManyRequests
Athena::HTTPKernel::Exception::Unauthorized
Athena::HTTPKernel::Exception::UnprocessableEntity
Athena::HTTPKernel::Exception::UnsupportedMediaType
Constructors#
.from_status(status : Int32 | ::HTTP::Status, message : String = "", cause : ::Exception | Nil = nil, headers : ::HTTP::Headers = ::HTTP::Headers.new) : self#
Helper method to return the proper exception subclass for the provided status. The message, cause, and headers are passed along as well if provided.
ameba:disable Metrics/CyclomaticComplexity
.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.
.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.
Methods#
#headers : ::HTTP::Headers#
Any HTTP response headers associated with self.
Some HTTP errors use response headers to give additional information about self.
#headers=(headers : ::HTTP::Headers)#
Any HTTP response headers associated with self.
Some HTTP errors use response headers to give additional information about self.
#to_json(builder : JSON::Builder) : Nil#
Serializes self to JSON in the format of {"code":400,"message":"Exception message"}