tiny-errors
v1.0.5
Published
Simple error class for your REST server # Installation `$ npm install --save tiny-errors` # Usage # Properties - [code](#code) - [message](#message) ## code ```javascript code: number ``` This code will be used as HTTP Status (200, 404, 403, 500...) ## me
Downloads
2
Readme
tiny-errors
Simple error class for your REST server
Installation
$ npm install --save tiny-errors
Usage
Properties
code
code: number
This code will be used as HTTP Status (200, 404, 403, 500...)
message
message: string
This message will be use to send to client
Methods
constructor
constructor(code: number, message: string) {...}
// Example
let error = new TinyErrors(400, 'Username "tinyRush" is duplicated')
parse
public static parse(error): TinyError {...}
// Example
// This method usually use to parse mongoose error to error with appropriate code (HTTP Status)
let error = TinyErrors.parse(mongooseValidationError);