module Athena::HTTPKernel::Exception
#
Exception handling in Athena is similar to exception handling in any Crystal program, with the addition of a new unique exception type, AHK::Exception::HTTPException.
When an exception is raised, Athena emits the AHK::Events::Exception event to allow an opportunity for it to be handled.
If the exception goes unhandled, i.e. no listener set an AHTTP::Response on the event, then the request is finished and the exception is re-raised.
Otherwise, that response is returned, setting the status and merging the headers on the exceptions if it is an AHK::Exception::HTTPException.
See AHK::Listeners::Error and AHK::ErrorRendererInterface for more information on how exceptions are handled by default.
To provide the best response to the client, non AHK::Exception::HTTPException should be rescued and converted into a corresponding AHK::Exception::HTTPException.
Custom HTTP errors can also be defined by inheriting from AHK::Exception::HTTPException or a child type.
A use case for this could be allowing for additional data/context to be included within the exception that ultimately could be used in a AHK::Events::Exception listener.