NAME
Net::Blossom::Server::Error - Typed Blossom server error
SYNOPSIS
use Net::Blossom::Server::Error;
Net::Blossom::Server::Error->throw(
status => 401,
reason => 'Unauthorized',
headers => { 'WWW-Authenticate' => 'Nostr' },
);
DESCRIPTION
Net::Blossom::Server::Error represents an expected server-side failure that gateway adapters can turn into an HTTP response. It is used for authorization failures and other controlled errors where the status code is part of the API.
CONSTRUCTOR
new
my $error = Net::Blossom::Server::Error->new(%args);
Required status must be an HTTP status code from 100 through 599.
Optional reason defaults to the empty string and must not contain CR or LF. Optional headers defaults to an empty hash reference. Header values must be defined scalars and must not contain CR or LF.
Unknown arguments or invalid values croak.
ACCESSORS
status
Returns the HTTP status code.
reason
Returns the reason string.
METHODS
throw
Net::Blossom::Server::Error->throw(%args);
Constructs and dies with a typed error object.
headers
my $headers = $error->headers;
Returns a copy hash reference of response headers.
header
my $value = $error->header($name);
Returns a header value using case-insensitive lookup.
as_response
my $response = $error->as_response;
Returns a Net::Blossom::Server::Response for the error.