Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matter-in-motion/mm-errors
Matter in motion protocol error codes
https://github.com/matter-in-motion/mm-errors
api errors matter-in-motion mmp protocol
Last synced: about 1 month ago
JSON representation
Matter in motion protocol error codes
- Host: GitHub
- URL: https://github.com/matter-in-motion/mm-errors
- Owner: matter-in-motion
- License: mit
- Created: 2016-02-16T23:59:45.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-09-22T15:53:42.000Z (over 5 years ago)
- Last Synced: 2024-12-11T20:43:48.162Z (about 2 months ago)
- Topics: api, errors, matter-in-motion, mmp, protocol
- Language: JavaScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## Matter In Motion. Error Codes
[![NPM Version](https://img.shields.io/npm/v/mm-errors.svg?style=flat-square)](https://www.npmjs.com/package/mm-errors)
[![NPM Downloads](https://img.shields.io/npm/dt/mm-errors.svg?style=flat-square)](https://www.npmjs.com/package/mm-errors)Common errors for [Matter in Motion](http://https://github.com/matter-in-motion/mm) protocol
## Errors codes:
* **4000** Call — general error to return
* **4100** Unauthorized — unauthorized
* **4104** ProviderNotFound — Auth provider not found
* **4110** Forbidden — forbidden
* **4120** NotValidToken — token not valid or expired
* **4200** RequestValidation — request validation failed
* **4210** ResponseValidation — response validation failed
* **4220** RequestTooLarge — request entity too large
* **4230** RequestEncode — request encode error
* **4235** RequestDecode — request decode error
* **4240** ResponseEncode — response encode error
* **4245** ResponseDecode — response decode error
* **4250** UnsupportedMedia — unsupported media
* **4255** NoFilesInRequest — no files found in request
* **4400** MethodNotFound — method not found
* **4500** Duplicate — duplicate entity
* **4540** NotFound — not found
* **5000** ServerError — server error
* **5100** NetworkError — network error## Usage
```js
const errors = require('mm-errors');
//when you need to return an error:
return errors.NotFound();
//or
throw errors.NotFound();
``````js
return error.Call(data, message);
//or
throw error.Call(data, message);
```You can add any data and/or message to errors;
## Custom errors
```js
const errors = require('mm-errors');
const CustomError = errors.Error(code, msg, toString);//and then you can use it
return CustomError();
//or
throw CustomError();
```* **code** — error code
* **message** — default message
* **toString** — optional toString functionLicense: MIT