1.0.5 • Published 7 years ago

tiny-errors v1.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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

License

MIT

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago