extracted hardcoded string in constant

This commit is contained in:
Evgeniy Filatov 2018-10-02 11:52:52 +03:00 committed by Pascal Precht
parent 517365353b
commit f79834a30d
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 3 additions and 1 deletions

View File

@ -1,6 +1,8 @@
const RunCode = require('./runCode.js'); const RunCode = require('./runCode.js');
const Utils = require('../../../utils/utils'); const Utils = require('../../../utils/utils');
const WEB3_INVALID_RESPONSE_ERROR = 'Invalid JSON RPC response';
class CodeRunner { class CodeRunner {
constructor(options) { constructor(options) {
this.config = options.config; this.config = options.config;
@ -94,7 +96,7 @@ class CodeRunner {
cb(null, value); cb(null, value);
} catch (error) { } catch (error) {
// Improve error message when there's no connection to node // Improve error message when there's no connection to node
if (error.message.indexOf('Invalid JSON RPC response') !== -1) { if (error.message.indexOf(WEB3_INVALID_RESPONSE_ERROR) !== -1) {
error.message += '. Are you connected to an Ethereum node?'; error.message += '. Are you connected to an Ethereum node?';
} }