Unfortunately there is no way to catch all the possible errors that might interrupt the script execution, i.e. maximum execution time exceeded, so the best is to do your best to prevent them i.e. by using if statements to run certain parts of your code if the required conditions are present otherwise exit "gracefully" / "elegantly".
Besides doing your best to prevent the errors happen, you could use try..catch statements to handle several run-time exceptions especially those that might not be worthy to spend too much programming time on prevent them to happen.
Since the transfer function is not getting a response from the functions being called, it might be better to keep all the try..catch in the transfer function, this way it might be easier to maintain.
You might also find useful to log the error messages, so you can confirm that the error were those that are expected to happen.
function Transfer(){
try {
Sparkasse();
} catch(error) {
console.log(error.message, error.stack);
}
try {
PayoneerHK();
} catch(error) {
console.log(error.message, error.stack);
}
try {
PayoneerDG();
} catch(error) {
console.log(error.message, error.stack);
}
try {
N26();
} catch(error) {
console.log(error.message, error.stack);
}
try {
Amex();
} catch(error) {
console.log(error.message, error.stack);
}
try {
Airwallex();
} catch(error) {
console.log(error.message, error.stack);
}
try {
Wise();
} catch(error) {
console.log(error.message, error.stack);
}
try {
Paypal();
} catch(error) {
console.log(error.message, error.stack);
}
}
Resources