simple message handler.
npm install simple-message
var message = require('simple-message');
var error = message.error.get('common.missing_required_parameter');
// console.log(error);
{
type: 'common.missing_required_parameter',
code: 400,
message: 'The request is missing a required parameter.'
}
load by json object
var message = require('simple-message');
message.load('error', {
"common.missing_required_parameter": [
400,
"The request is missing a required parameter."
],
"common.method_not_allowed": [
400,
"The API call is correct, but the method is not allowed."
],
"common.unexpected_parameter": [
400,
"The request specifies an unexpected parameter."
],
"common.invalid_json_string": [
400,
"Problems parsing JSON."
]
});
load by remote json file.
var message = require('simple-message');
message.load('error', 'json format file url', function(err, item) {
console.log(item['common.missing_required_parameter'][1], message.error.get('common.missing_required_parameter').message);
});
load by remote yaml file.
message.loadYAML('error', 'yaml format file url', function(err, item) {
console.log(item['common.missing_required_parameter'][1], message.error.get('common.missing_required_parameter').message);
});
simple-message is licensed under the MIT license.