Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 703 Bytes

getting-started.md

File metadata and controls

39 lines (27 loc) · 703 Bytes

Exceptions module

Exceptions module is a exception instance to facilitate the creation of custom exceptions. It uses i18next to translate the exception messages.

Usage

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();
}