Closed ivanfuzuli closed 3 years ago
This is expected as that's how JavaScript works. The .catch
in the second example will catch the error and thus the error won't further go down the chain.
If you don't want that to happen you can rethrow the error in the catch
:
axios.get("not-found").catch((error) => {
// Handle errors you can recover from
// ...
// Rethrow any errors that you haven't handled
throw error;
});
I use axiosMockAdapter with { onNoMatch: "throwException" } config. If there is no catch block it throws error as expected. But if there is a catch in promise chain it doesn't throw anything.
This throws error.
This doesn't throw.