All files / src/util errors.js

100% Statements 8/8
100% Branches 0/0
100% Functions 5/5
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                1x   1x     1x     1x     1x 1x 1x     1x      
/**
 * @file throw exact errors
 * @author atom-yang
 */
 
/**
 * errors related to requests
 */
export const RequestError = {
  InvalidNumberOfRPCParams() {
    return new Error('Invalid number of input parameters to RPC method');
  },
  InvalidConnection(host) {
    return new Error(`CONNECTION ERROR: Couldn\'t connect to node ${host}.`);
  },
  InvalidProvider() {
    return new Error('Provider not set or invalid');
  },
  InvalidResponse(error, result) {
    const message = `Invalid JSON RPC response: ${JSON.stringify(result)}`;
    console.error(`error ${error.toString()} \n ${message}`);
    return new Error(message);
  },
  ConnectionTimeout(ms) {
    return new Error(`CONNECTION TIMEOUT: timeout of ${ms} ms archived`);
  }
};