An async function wraps return loadAccount() in try/catch. Assume loadAccount returns a promise that rejects asynchronously. The caller sees a rejection instead of the fallback in catch. Explain why and how you would fix it.
Returning the promise lets the async function adopt its eventual rejection, but no exception is thrown while executing that try block. Write return await loadAccount() inside try so the rejection is thrown at the await expression and caught locally. A synchronous throw while calling loadAccount would already be caught by the original code.
What a Strong Answer Covers
Distinguish a rejected promise from a synchronous throw.
Explain why awaiting inside the try lets the local catch run.
Follow-up Interview Question · Where should the error be handled if only the caller knows the appropriate fallback?