API reference / @evolu/common / Type / createTypeErrorFormatter
Function: createTypeErrorFormatter()
function createTypeErrorFormatter<Error>(format): TypeErrorFormatter<Error>;
Defined in: packages/common/src/Type.ts:562
Creates a formatter function for TypeError.
The formatter generates human-readable error messages using a custom formatting function and a safely stringified error value.
Example
const formatStringError = createTypeErrorFormatter<StringError>(
(value) => `A value ${value} is not a string.`,
);
Type Parameters
| Type Parameter |
|---|
Error extends TypeError<Capitalize<string>> |
Parameters
| Parameter | Type |
|---|---|
format | (error) => string |
Returns
TypeErrorFormatter<Error>