Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
id: opts.id || this.randomId(),
jsonrpc: '2.0',
result: response
}
} catch (err) {
const errMsg = err.message.replace(/"/g, "'")
l.error('JsonRpcService - method() / ', errMsg)
let error
if (errMsg.match(/^Returned error/)) {
error = new errors.Error(err.message)
} else if (errMsg.match(/^Invalid number of parameters/)) {
error = new errors.ArgumentError('Invalid number of params used', err)
} else if (errMsg.match(/^(?:CONNECTION ERROR|CONNECTION TIMEOUT|Provider not set or invalid)/)) {
error = new errors.ConnectionError('Impossible to connect to node.', err)
} else if (errMsg.match(/^Invalid JSON RPC response/)) {
error = new errors.InvalidOperationError('Invalid JSON RPC response', err)
} else {
error = new errors.Error('Invalid JSON RPC response from node')
}
throw error
}
}