Repository navigation
v0.5.0
Every failure reaches the application's onError hooks — a 404, a 405 and a rate limit's refusal included — so one hook sets the format of every error, and errors in @tetsujs/openapi describes that format in the document.
Breaking changes
@tetsujs/core:404and405reach the application'sonErrorhooks as anHttpError, like every other failure. AnonErrorhook that answers every error — or logs each one — now sees unmatched paths and methods too. An application withoutonErrorhooks answers them as before, with the same response and at the same cost.@tetsujs/rate-limit: a refusal is a thrownHttpErrorwithretryAfterin its body, and reaches the application'sonErrorhooks. It used to be a returnedResponsethatonErrornever saw.
Added
@tetsujs/openapi:errorsinopenapi()anddocs()— an error format of the application's own, for the document to describe the framework's failures, the hooks' refusals and the routes' own envelopes in it.schemadescribes one failure from its status, code, message and fields;discriminatornames the top-level field with the code;codereads the code from a route's schema, for a format that nests it. A definition that differs from the kept one is now compared at every depth, so a nested format's missing field is reported by its path.
Changed
@tetsujs/core: the error path is synchronous until something on it waits, as the success path is. Every failure theonErrorhooks see takes it — a thrownHttpError, a validation failure, a refusal — and each now costs 110–170 ns less, a refusal through the pipeline 776 ns where it was 880.
Moving from 0.4
An onError hook on the application now receives 404, 405 and a rate limit's 429 as an HttpError. A hook that maps only errors it knows — returning nothing for the rest — needs no change: the default envelope answers as before. A hook that answers or logs every error should check error.status if those three are not meant for it.
Full Changelog: v0.4.2...v0.5.0