Reputation: 1161
I'm using a few external API's (some in timers, every minute or so) and sometimes I get some connection errors because of network problems or because the external systems are down for some reason. When I get this errors, the app restarts, and if the error persists the app continues restarting.
Any ideas on how can I ignore the connection error and keep the app running?
Code Example:
try {
var req = https.request(options, callback);
req.write(JSON.stringify(params));
req.end();
} catch (e) {
throw e;
}
Upvotes: 0
Views: 79
Reputation: 23544
Based on your code example. You're doing throw e
inside your try catch. Essentially, you're catching an error and then throwing the error. Just do console.error(err)
or however you want to handle that error, without throwing. This is what will cause your instance to stop.
Upvotes: 3