⚠️ This project is still in early alpha. Please report bugs on GitHub.

Utilities
Errors

Errors utility

Out of the box, validathor ships with two custom error types.

These are used internally but could be useful for example to test that the right error type is thrown in your own code.

Arguments

  • message (optional, string): A custom error message to be displayed.
  • cause (optional, Error): The original error that caused this type error. If not provided, a generic error with the default message will be set as the cause.

Example

import { ValidationError, TypeError } from '@nordic-ui/validathor';
 
throw new ValidationError('Maximum length must be a positive number');
throw new TypeError('Expected a number');