API Reference / @evolu/common / Type / createTypeErrorFormatter

Function: createTypeErrorFormatter()

function createTypeErrorFormatter<Error>(format): TypeErrorFormatter<Error>;

Defined in: packages/common/src/Type.ts:357

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

ParameterType
format(error) => string

Returns

TypeErrorFormatter<Error>

Was this page helpful?