mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
fix(lint): keep the caught error as the cause of the one rethrown
ESLint 10's recommended set added preserve-caught-error: a catch block that
throws a new error has to pass the caught one as its cause. Five places
caught an error and threw a plainer one in its place — fetching the OIDC
configuration, sending a confirmation email, triggering a webhook,
validating a Zapier API token, rendering an email — and each failed the
lint.
Each now passes `{ cause: err }`. The thrown error keeps its message and
type; what it gains is the original, which Node prints after it as
`[cause]`. render-email-with-i18n.tsx also loses its stale ban-types
disable comment, as the five files in the commit before did.
Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
@@ -57,6 +57,7 @@ const load = async (wellKnownUrl: string): Promise<OpenIdConfiguration> => {
|
||||
|
||||
throw new Error(
|
||||
`Failed to fetch OIDC configuration: ${err instanceof Error ? err.message : String(err)}`,
|
||||
{ cause: err },
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,6 +64,6 @@ export const sendConfirmationToken = async ({
|
||||
return { success: true };
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw new Error(`Failed to send the confirmation email`);
|
||||
throw new Error(`Failed to send the confirmation email`, { cause: err });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -32,6 +32,6 @@ export const triggerWebhook = async ({ event, data, userId, teamId }: TriggerWeb
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw new Error(`Failed to trigger webhook`);
|
||||
throw new Error(`Failed to trigger webhook`, { cause: err });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,6 +15,6 @@ export const validateApiToken = async ({ authorization }: ValidateApiTokenOption
|
||||
|
||||
return await getApiTokenByToken({ token });
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to validate API token`);
|
||||
throw new Error(`Failed to validate API token`, { cause: err });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
export const renderEmailWithI18N = async (
|
||||
component: React.ReactElement,
|
||||
options?: RenderOptions & {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
lang?: SupportedLanguageCodes | (string & {});
|
||||
},
|
||||
) => {
|
||||
@@ -27,6 +26,6 @@ export const renderEmailWithI18N = async (
|
||||
return renderWithI18N(component, { i18n, ...otherOptions });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw new Error('Failed to render email');
|
||||
throw new Error('Failed to render email', { cause: err });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user