Imagine having 2 catch
blocks in your code:
try {
axios.get('https://example.com', {})
.then(function (responseOne: any) {
return axios.post('https://example.com', {}, {})
}).then(async function (responseTwo: any) {
return axios.put('https://example.com', {}, {})
}).then(async function (responseThree: any) {
return axios.post('https://example.com', {}, {})
}).then(async function () {
reply.send
}).catch(error) => {}
} catch(errorOuter) => {}
Based on my understanding, it seems like the outer catch will only be triggered if the first axios call is await axios.get(...)
. Is this assumption correct? What happens if each of the then
blocks are also awaited?
If the code stays as it is, would the inner catch be the only one to be executed? If that's the case, then I can probably remove the outer catch altogether.