If I am facing the situation where multiple method calls to another class are possible, each of which could potentially throw the same exception that I am unable to modify, how can I handle each Exception separately without allowing the rest of the function to continue execution?
For instance:
async mightThrowExceptions() {
var call1 = await this.api.sampleMethod(); //Possible exception of type 'E'
//Should not proceed if call1 throws an exception
var call2 = await this.api.dependantFrom1(call1); //Possible exception of type 'E'
//Should not proceed if call2 throws an exception
var call3 = await this.api.dependantFrom2(call2); //Possible exception of type 'E'
/*
If call1 throws an exception, perform:
console.log('call1 threw exception');
If call2 throws an exception, perform:
console.log('call2 threw exception');
If call3 throws an exception, perform:
console.log('call3 threw exception');
*/
}