Skip to main content

index/type-aliases/ErrorCode.md

ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES]

Type for error codes - use for type-safe error code handling

Example​

function handleError(code: ErrorCode) {
switch (code) {
case ERROR_CODES.REQUIRED:
return 'This field is required';
case ERROR_CODES.INVALID_FORMAT:
return 'Invalid format';
// ... other cases
}
}