api_error_generator
v1.0.4
Published
A useful js library for generating and error list
Downloads
2
Readme
API Errors
A useful js library for generating and error list
Usage
JS
//Import Library
var apierrors = require("api_error_generator");
//Generating the code
error_list = apierrors.generateCodes({
ERR_BASIC: { msg: "Basic Error" },
ERR_HTTP_BASIC: { msg: "Basic HTTP", http_code: 400 }
});
// => {"ERR_BASIC":{"msg":"Basic Error","code":0},"ERR_HTTP_BASIC":{"msg":"Basic HTTP","http_code":400,"code":1}}
//Convert a json file to a js file
apierrors.convertFile(
inputFilename,
outputFilename,
(format = false),
(codeCounterBase = 0)
);
CLI
generateapierrors -i input.json -o errors.js -f -c 0
Args:
--input or -i
The input file, default toerrors.json
--output or -o
The output file, defaults toerrors.js
--format or -f
Whether or not to format the the output file, defaults tofalse
--counter or -c
Where to start the counter, default to0