Skip to content

tinyRush/tiny-errors

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published