Every error the framework answers by itself uses one envelope. This page
lists those errors, the default code of each status, and the classes and
functions behind them. Errors explains the model.
no route matches the path and there is no fallback
405
METHOD_NOT_ALLOWED
Method Not Allowed
the path exists but not the method; Allow lists the path’s methods
413
BODY_TOO_LARGE
Body exceeds the configured limit
the body is over maxBodySize
422
VALIDATION_FAILED
Validation failed
a request part failed its schema; carries issues; 400 with validation: { status: 400 }
426
UPGRADE_REQUIRED
Upgrade Required
a WebSocket endpoint’s path was requested without a handshake
500
INTERNAL_SERVER_ERROR
Internal Server Error
an error that is not an HttpError and no onError hook answered; a broken response contract; a stream returned bare
@tetsujs/rate-limit adds RATE_LIMITED,
429 unless its status option says otherwise, with retryAfter in
seconds in the body and a retry-after header.
Every failure above reaches the application’s onError hooks before it
is answered: as an HttpError, or, for a 500, as the error that caused
it. Only the application’s hooks run for a 404 and a 405.
Two answers reach no hook:
the last-resort 500, sent when the error path itself kept failing;
a body larger than Bun’s own maxRequestBodySize, which Bun refuses with
a bare 413 and no envelope. createApp raises that cap above the
largest maxBodySize when it needs to.
An HttpError without a body, and errorBody() or httpError() without
an error, take the code and message from the status. The message is the
reason phrase. The code is that phrase in upper snake case, apostrophes
dropped. A status not in this list gets HTTP <status> and
HTTP_<status>.
Status
error
Status
error
400
BAD_REQUEST
421
MISDIRECTED_REQUEST
401
UNAUTHORIZED
422
UNPROCESSABLE_CONTENT
402
PAYMENT_REQUIRED
423
LOCKED
403
FORBIDDEN
424
FAILED_DEPENDENCY
404
NOT_FOUND
425
TOO_EARLY
405
METHOD_NOT_ALLOWED
426
UPGRADE_REQUIRED
406
NOT_ACCEPTABLE
428
PRECONDITION_REQUIRED
407
PROXY_AUTHENTICATION_REQUIRED
429
TOO_MANY_REQUESTS
408
REQUEST_TIMEOUT
431
REQUEST_HEADER_FIELDS_TOO_LARGE
409
CONFLICT
451
UNAVAILABLE_FOR_LEGAL_REASONS
410
GONE
500
INTERNAL_SERVER_ERROR
411
LENGTH_REQUIRED
501
NOT_IMPLEMENTED
412
PRECONDITION_FAILED
502
BAD_GATEWAY
413
CONTENT_TOO_LARGE
503
SERVICE_UNAVAILABLE
414
URI_TOO_LONG
504
GATEWAY_TIMEOUT
415
UNSUPPORTED_MEDIA_TYPE
505
HTTP_VERSION_NOT_SUPPORTED
416
RANGE_NOT_SATISFIABLE
506
VARIANT_ALSO_NEGOTIATES
417
EXPECTATION_FAILED
507
INSUFFICIENT_STORAGE
418
IM_A_TEAPOT
508
LOOP_DETECTED
510
NOT_EXTENDED
511
NETWORK_AUTHENTICATION_REQUIRED
The framework’s own 413 uses BODY_TOO_LARGE, not the default
CONTENT_TOO_LARGE.
sends a report to the application’s reportError, or prints it when there is none
A report is { source, error, ctx? }. The framework’s sources are
unhandled, response, onError, errorResponse, afterResponse,
websocket, stream and shutdown, and a package may add its own. See
Errors.
Without a reportError, each report is printed on console.error with a
[tetsu] prefix.