Beispiel #1
0
].reduce(function(prev, next) {
    var spec = next.name.split('.');
    var Ctor = create(spec.pop(), spec.join('.'), next.defaultMessage, next);
    prev[next.name] = function(params) {
        return new Ctor({params: params});
    };
    return prev;
}, {});
Beispiel #2
0
var iterate = errors => Object.keys(errors).forEach(name => {
    var Err = create(name, Iso, errors[name]);
    module.exports[name] = cause => new Err(convert(cause));
});
Beispiel #3
0
var create = require('ut-error').define;

var Iso = create('iso8583');

var errors0 = require('./iso0').errors;
var errors1 = require('./iso1').errors;
var Generic = create('generic', Iso, 'generic error');

function convert(msg) {
    return Object.keys(msg).reduce((prev, current) => {
        prev[(/^[^A-Za-z_]/.test(current) ? 'iso' : '') + current] = msg[current];
        return prev;
    }, {});
}

module.exports = {
    generic: cause => new Generic(convert(cause))
};

var iterate = errors => Object.keys(errors).forEach(name => {
    var Err = create(name, Iso, errors[name]);
    module.exports[name] = cause => new Err(convert(cause));
});

iterate(errors0);
iterate(errors1);
const create = require('ut-error').define;

const jsonRPC = create('jsonRPC');
const invalidJson = create('invalidJson', jsonRPC, 'Invalid json');
const invalidVersion = create('invalidVersion', invalidJson, 'Invalid jsonrpc version');
const invalidMethod = create('invalidMethod', invalidJson, 'Invalid or missing method');
const invalidPayload = create('invalidPayload', invalidJson, 'Invalid or missing jsonrpc payload');
const invalidMessageID = create('invalidMessageID', invalidJson, 'Invalid message id');

module.exports = {
    jsonRPC,
    invalidJson,
    invalidVersion,
    invalidMethod,
    invalidPayload,
    invalidMessageID
};