Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 1x | import {capitalize, checkSubject, type PrimitiveDescriptor} from '../engine.ts';
/** `error` — the domain error layer. */
const error: PrimitiveDescriptor = {
id: 'error',
title: 'Typed errors',
skill: 'blong-error',
summary: 'Domain error layer: parameterised messages, HTTP status codes, wrapping.',
kinds: ['layer', 'inline', 'librarySet'],
defaultKind: 'layer',
roots: ['error'],
check(ctx) {
return checkSubject(ctx.subject);
},
files(ctx) {
const name = ctx.object;
return [
{
path: 'error/error.ts',
content: `/**
* ${ctx.subject} domain errors.
* Keys are '<subject>.<entity>.<reason>' so they can be referenced as
* errors.${ctx.subject}${capitalize(name)}NotFound etc.
*/
export default {
'${name}.notFound': '${capitalize(name)} {${name}Id} not found',
'${name}.invalid': {message: '${capitalize(name)} is invalid', statusCode: 400},
};
`,
},
];
},
};
export default error;
|