1.0.4 • Published 2 years ago

@secjs/exceptions v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Exceptions 🛑

Very simple Exceptions for NodeJS Applications and other SecJS packages

GitHub followers GitHub stars

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.

Installation

npm install @secjs/exceptions

Usage

BaseException

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!' })

SecJS Exceptions

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'

License

Made with 🖤 by jlenon7 :wave: