Changelog - 2026-07-17
Error Module Redesign
Breaking ChangeIn one line. One message shape, { text, code, args }, is used from definition to response, so normalized is the only place to read an error's code and args.
What changed
- One shape. A definition, the
getErrorinput andnormalizedall speak{ text, code, args }.messageis either the string or an object likenormalized. - Flat duplicates removed. No
error.messageCode, noextra.messageArgs, no top-levelmessageCodeon the wire.normalized.argsis always populated ({}when empty). - Throw sites keep working.
getError({ message: 'boom', messageCode: 'a.b' })behaves as before. - Catalogued form takes a partial override. For example
getError({ error: SlugErrors.TAKEN, message: { args: { slug: 've-hoa-nhac' } } }). Omit a field and the definition supplies it. AppErrorMiddlewarereplaces theappErrorHandlerfunction.- Spreading a definition is safe now. It used to degrade to
core.system_errorsilently. - Fixes. A malformed
error(for examplegetError({ message: 'wrapper', error: 'boom' })) threw aTypeErrorinside the error constructor and masked the original failure. It degrades instead, and passing a caught error aserroris now a compile error: usecause.MessageCode.isValid(123)threw; it now returnsfalse, andresolvefalls back toMessageCode.DEFAULTfor any non-string.
typescript
getError({ message: 'Only %{n} left', messageCode: 'stock.low', messageArgs: { n: 2 } }); // flat
getError({ message: { text: 'Only %{n} left', code: 'stock.low', args: { n: 2 } } }); // nested
getError({ error: StockErrors.LOW, messageArgs: { n: 2 } }); // cataloguedPrecedence, most specific first: code is message.code, then the definition's message.code, then messageCode. Args are message.args, then messageArgs, then the definition's message.args.
Who is affected
- Anyone compiled against
@venizia/ignis-inversion@0.1.1-0.TErrorDefinitionchanged shape andApplicationError.messageCodewas removed. Migrate as below. - Everyone else. No action needed.
ErrorScopes,category?, thegetErrorentry points,isApplicationError, the five middleware branches, their status codes and the production leak boundary are unchanged. Unknown keys still go toextra, andcausestill reachesError.cause.
Breaking changes
WARNING
Two classes of change are not caught by the compiler: reads of error.messageCode and error.extra?.messageArgs.
Before:
typescript
// definition
{ key: 'server.core.user.duplicate', statusCode: 409, message: 'Taken: %{email}', messageArgs: {...} }
// reads
error.messageCode
error.extra?.messageArgs
body.messageCode // HTTP
// middleware
server.onError(appErrorHandler({ logger, rootKey }));
// transform
transform: s => ({ code: s.messageCode, args: s.extra?.messageArgs ?? {}, text: 'VI' })After:
typescript
// definition
{ message: { text: 'Taken: %{email}', code: 'server.core.user.duplicate', args: {...} }, statusCode: 409 }
// reads
error.normalized.code
error.normalized.args
body.normalized.code // HTTP
// middleware (an IProvider<ErrorHandler>)
server.onError(new AppErrorMiddleware({ logger, rootKey }).value());
// transform
transform: s => ({ ...s.message, text: 'VI' })TRegisterErrors now indexes ['message']['code'] instead of ['key'].
Migration:
- Inside every
TErrorDefinition:key: 'x'becomesmessage: { code: 'x', ... },message: 'text'becomesmessage: { text: 'text', ... }, andmessageArgs: {...}becomesmessage: { args: {...} }. - Reads of a definition:
definition.keybecomesdefinition.message.code. Hand-rolledIErrorKeyRegistryaugmentations:['key']becomes['message']['code']. - Registration:
appErrorHandler({...})becomesnew AppErrorMiddleware({...}).value(). - Check by hand, because
tscstays green: grep for.messageCodeandextra?.messageArgsand repoint them to.normalized.codeand.normalized.args. If your client types against a differentApplicationError(a UI package of your own), the read silently yieldsundefined, which shows as a blank error toast. Also checkas anyand catch-variable reads.
typescript
translate(error.messageCode, error.extra?.messageArgs); // before
translate(error.normalized.code, error.normalized.args); // after