Skip to content

Commit

Permalink
exception: when error occurs does not make exit node on network looping
Browse files Browse the repository at this point in the history
- replace error message with the actual log result

Signed-off-by: Salman Wahib <[email protected]>
  • Loading branch information
sxlmnwb committed Aug 12, 2023
1 parent 0d0a45f commit f757169
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
44 changes: 36 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,34 @@ client.on('message', async msg => {
if (commandParts.length >= 3) {
const networks = commandParts.slice(1, -1);
const intervalString = commandParts[commandParts.length - 1];
const errors = [];

if (intervalString === '--stop') {
stopLoop(networks, chat);
} else {
startMainnetLoop(client, networks, intervalString, chat);
for (const network of networks) {
try {
await useMainnet(network);
} catch (error) {
console.error(error);
errors.push(error.message);
}
}
if (errors.length > 0) {
msg.reply(errors.join('\n'));
} else {
startMainnetLoop(client, networks, intervalString, chat);
}
}

} else if (commandParts.length === 2) {
const network = commandParts[1];
if (network !== '--help') {
try {
const info = await useMainnet(network);
msg.reply(info);
await useMainnet(network);
} catch (error) {
console.error(error);
msg.reply(`WARN ${network} on mainnet not response, please check your log 💀⁉️`);
msg.reply(error.message);
}
}
}
Expand All @@ -49,20 +63,34 @@ client.on('message', async msg => {
if (commandParts.length >= 3) {
const networks = commandParts.slice(1, -1);
const intervalString = commandParts[commandParts.length - 1];
const errors = [];

if (intervalString === '--stop') {
stopLoop(networks, chat);
} else {
startTestnetLoop(client, networks, intervalString, chat);
for (const network of networks) {
try {
await useTestnet(network);
} catch (error) {
console.error(error);
errors.push(error.message);
}
}
if (errors.length > 0) {
msg.reply(errors.join('\n'));
} else {
startTestnetLoop(client, networks, intervalString, chat);
}
}

} else if (commandParts.length === 2) {
const network = commandParts[1];
if (network !== '--help') {
try {
const info = await useTestnet(network);
msg.reply(info);
await useTestnet(network);
} catch (error) {
console.error(error);
msg.reply(`WARN ${network} on testnet not response, please check your log 💀⁉️`);
msg.reply(error.message);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/useCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function useCommand(msg) {
return '```/testnet <network>```\n```/testnet <network> <interval>```\n```/testnet --help```';

case '/testnet --help':
return 'This tool was created to very simplify validator monitoring with cosmos based node, with .env COSMOS_* variables that you can customize.\n\nFor use ```/testnet <network> <interval | --stop>```, where ```<interval>``` is a number followed by "m" (for minutes) or "h" (for hours).\n\nFor example :\n```/testnet cosmost```\n```/testnet cosmost 1m```\n```/testnet cosmost 12h```\n```/testnet cosmost --stop```';
return 'This tool was created to very simplify validator monitoring with cosmos based node, with .env COSMOST_* variables that you can customize.\n\nFor use ```/testnet <network> <interval | --stop>```, where ```<interval>``` is a number followed by "m" (for minutes) or "h" (for hours).\n\nFor example :\n```/testnet cosmost```\n```/testnet cosmost 1m```\n```/testnet cosmost 12h```\n```/testnet cosmost --stop```';

case '/ping':
return '```/ping <destination>```\n```/ping --help```';
Expand Down

0 comments on commit f757169

Please sign in to comment.