Very simple Exceptions for NodeJS Applications and other SecJS packages
The intention behind this repository is to always maintain a viable and simple exception creator to use in any type of NodeJS Framework
and
inside all SecJS
packages.
npm install @secjs/exceptions
Create your own custom exception extending BaseException methods
class MyCustomException extends BaseException {
constructor(content: string | object = 'My default error', status = 400) {
super(MyCustomException.name, content, status);
}
}
throw new MyCustomException({ error: 'object', use: 'as you want!' })
Or if you prefer, you can use the already built in exception from this package
import {
BadRequestException,
ForbiddenException,
InternalServerException,
InvalidMethodException,
NotFoundException,
NotImplementedException,
UnauthorizedException,
UnprocessableEntityException,
UnsupportedMediaException,
} from '@secjs/exceptions'
Made with ๐ค by jlenon7 ๐