HttpErrorHttpError — throw a status (and optional body) from anywhere under a [Web]App; the dispatcher maps it onto the response:
(req.header:'authorization').defined?.else:{ HttpError.throw:401 }; HttpError.throw:422 body:#{ 'error':'bad email' };
Root-level by convention, not constraint: it reads as a sibling of the built-in error family (IoError, ValueError, TimeoutError, ParseError).
Throw an HttpError carrying just a status; the [Web]App dispatcher maps it onto the response.
(req.header:'authorization').defined?.else:{ HttpError.throw:401 }
Throw an HttpError with a status and a body for the dispatcher to render.
HttpError.throw:422 body:#{ 'error':'bad email' }
The optional body for the error response (rendered through the app's respondTo: conventions), or nil.
Internal: default the status to 500 and derive the message ('HTTP 422').
The HTTP status to answer with.