in src/handler.ts [493:528]
async function tryWithErrorHandling<T>(
action: () => Promise<T>,
onError: (error: ErrorResponse) => void,
): Promise<T | undefined> {
try {
return await action();
} catch (ex) {
if (ex instanceof RestError) {
const correlationId = ex.response?.headers.get(
"x-ms-correlation-request-id",
);
logError(`Request failed. CorrelationId: ${correlationId}`);
const { error } = ex.details as CloudError;
if (error) {
onError(error);
return;
}
}
if (ex instanceof CustomPollingError) {
const correlationId = ex.response?.headers.get(
"x-ms-correlation-request-id",
);
logError(`Request failed. CorrelationId: ${correlationId}`);
const { error } = ex.details;
if (error) {
onError(error);
return;
}
}
throw ex;
}
}