Skip to content

Repository files navigation

errorlings

Common errors for your application.

API

Create error (all parameters optional and can be passed in any order)

conste=newCustomEror(status: number,message: string,code: string,inner: Error,{data: any});

Rules of detecting type of parameter:

  • typeof number: status
  • first string: message
  • second string: code
  • instanceof Error: inner
  • object with key data: data

Using options object as parameter:

consterr=newCustomEror({status?: number;data?: any;code?: string;inner?: Error;message?: string;});

Error classes and defaults

  • ExceptionError
  • ForbiddenError (status: 403, message: You don't have permission to do that.)
  • NotFoundError (status: 404)
  • ValidationError (status: 400)

Changelog

See CHANGELOG.md

Similar Projects

About

Custom errors

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages