Exceptions module is a exception instance to facilitate the creation of custom exceptions. It uses i18next to translate the exception messages.
Install the package on your project:
pnpm add @x-spacy/exceptions
Import the module:
import { Exception } from '@x-spacy/exceptions';
Create a new exception and instantiate it:
import { Exception } from '@x-spacy/exceptions';
export class MyException extends Exception {
constructor() {
super(400, 'MyException');
}
}
Use the exception:
import { MyException } from './my-exception';
function throwMyException() {
throw new MyException();
}