For example I have an async function:
prepAttrsRef.current.addEventListener('documentstatechanged', async (evt: CustomEvent<FlowDocumentState>) => {
if (evt.detail.draftState === 'unpublished-changes') {
dispatch(updateIsFlowpublished(false));
await publishPrepFlow();
}
if (evt.detail.draftState === 'all-changes-published') {
await cleanSteps[0].selectAsync();
}
}
await getAndDispatchPrepColumns();
});
Should I always enclose the await
lines with try/catch or at least a catch to handle the potential case that the promise could be rejected? (Although I don't know if the promise will be reject or not, since I am calling the API created by others)