If I remove the second try/catch block, would an exception occurring in the IIFE bubble-up to the first try/catch block, considering the IIFE is preceded by return
?
I am trying to eliminate unnecessary try/catch blocks and understand bubbling.
const run = (
identifier: string
): Promise<{
installationId: string;
}> =>
new Promise(async (resolve, reject) => {
try {
const { installationId } = await getInstallation(identifier);
await updateInstallation(installationId);
resolve({
installationId,
});
} catch (errorCode) {
if (errorCode === "installationNotFound")
return (async () => {
try {
const installationId = await insertInstallation(identifier);
resolve({
installationId,
});
} catch (errorCode) {
reject(errorCode);
}
})();
reject(errorCode);
}
});