Validation error responses
The Express controller adapter reports schema failures as HTTP 422 Problem
Details by default. For application validation, throw
unprocessableEntity(message, details) from @tagna/udiot/server inside a
controller handled by the adapter. Returning or throwing an error elsewhere
still requires the corresponding application error handler.
import assert from 'node:assert/strict';
import { unprocessableEntity } from '@tagna/udiot/server';
const error = unprocessableEntity('Invalid request', {
code: 'INVALID_RANGE',
errors: [{ field: 'end', message: 'End precedes start' }],
});
assert.ok(error instanceof Error);
Use stable application error codes and field paths. Do not echo passwords, tokens, SQL errors or internal stack traces in public responses. Keep detailed diagnostics in appropriately redacted server logs. Translate safe user messages in your application; the internal formatter/i18n helpers are not public exports.
For forms, inspect FormManager.getState().errors; this is UI feedback, not
server authorization. See server errors.