Skip to content

Commit

Permalink
Use exit code constant for general errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Oct 24, 2018
1 parent 3171c1e commit 3d706dd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion scripts/privateKeyToAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ require('dotenv').config({
path: path.join(__dirname, '..', '.env')
})
const { privateKeyToAddress } = require('../src/utils/utils')
const { EXIT_CODES } = require('../src/utils/constants')

const privateKey = process.env.VALIDATOR_ADDRESS_PRIVATE_KEY

if (!privateKey) {
console.error('Environment variable VALIDATOR_ADDRESS_PRIVATE_KEY is not set')
process.exit(1)
process.exit(EXIT_CODES.GENERAL_ERROR)
}

const address = privateKeyToAddress(privateKey)
Expand Down
3 changes: 2 additions & 1 deletion scripts/resetLastBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require('dotenv').config({
path: path.join(__dirname, '../.env')
})
const { id } = require('../config/base.config')
const { EXIT_CODES } = require('../src/utils/constants')

const redis = new Redis(process.env.REDIS_URL)

Expand All @@ -22,7 +23,7 @@ if (process.argv.length < 4) {

function logError(message) {
console.log(message)
process.exit(1)
process.exit(EXIT_CODES.GENERAL_ERROR)
}

function getRedisKey(name) {
Expand Down
4 changes: 2 additions & 2 deletions src/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const VALIDATOR_ADDRESS = privateKeyToAddress(VALIDATOR_ADDRESS_PRIVATE_KEY)

if (process.argv.length < 3) {
logger.error('Please check the number of arguments, config file was not provided')
process.exit(1)
process.exit(EXIT_CODES.GENERAL_ERROR)
}

const config = require(path.join('../config/', process.argv[2]))
Expand Down Expand Up @@ -60,7 +60,7 @@ async function initialize() {
})
} catch (e) {
logger.error(e.message)
process.exit(1)
process.exit(EXIT_CODES.GENERAL_ERROR)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
},
DEFAULT_UPDATE_INTERVAL: 600000,
EXIT_CODES: {
GENERAL_ERROR: 1,
INCOMPATIBILITY: 10,
MAX_TIME_REACHED: 11
}
Expand Down
4 changes: 2 additions & 2 deletions src/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { EXIT_CODES } = require('./utils/constants')

if (process.argv.length < 3) {
logger.error('Please check the number of arguments, config file was not provided')
process.exit(1)
process.exit(EXIT_CODES.GENERAL_ERROR)
}

const config = require(path.join('../config/', process.argv[2]))
Expand Down Expand Up @@ -47,7 +47,7 @@ async function initialize() {
})
} catch (e) {
logger.error(e)
process.exit(1)
process.exit(EXIT_CODES.GENERAL_ERROR)
}
}

Expand Down

0 comments on commit 3d706dd

Please sign in to comment.