ym-error-codes v1.0.0
REST API Error Messages Generator - Module to automate and standardize error messages on REST API based services.
All codes are copy from this Wiki HTTP Status Codes
Installation
$ npm i ym-error-codes --save
Implementation
By default, ym-error-codes
message comes with English (United States) locale strings. If you need other locales, pass the key and the string value on the class instantiation.
//Import; //Instantiation, english by defaultconst Error = //Instantiation with Burmese as default languageconst Error = 'my'
Note: Currently, the available languages for displaying error messages are English ('en') and Myanmar ('my').
Basic usage
Error; /* will return { "status": 200, "name": "Ok", "message": "Request has successfully been completed." }*/
Using Custom Error Message
You can change the error message with custom message.
Error; /* will return { "status": 200, "name": "Ok", "message": "Your custom message" }*/
Adding New Error
You can add your custom error codes
Error; Error; /* will return { "status": 1, "name": "New Error", "message": "Your new error message" }*/
Warning: If your new error code are the same with the existing error code, the existing error code will be overridden.