Docstring for captureError

This commit is contained in:
Konstantin Wohlwend 2025-07-29 01:37:26 -07:00
parent 343ae8dcfd
commit dd8783af09
3 changed files with 12 additions and 3 deletions

View File

@ -56,7 +56,7 @@ export class OAuthModel implements AuthorizationCodeModel {
({ domain, handler_path }) => new URL(handler_path, domain).toString()
);
} catch (e) {
captureError("get redirect uris", {
captureError("get-oauth-redirect-urls", {
error: e,
projectId: tenancy.project.id,
domains: tenancy.config.domains,

View File

@ -112,6 +112,15 @@ registerErrorSink((location, error, ...extraArgs) => {
globalVar.stackCapturedErrors.push({ location, error, extraArgs });
});
/**
* Captures an error and sends it to the error sinks (most notably, Sentry). Errors caught with captureError are
* supposed to be seen by an engineer, so they should be actionable and important.
*
* The location string is a machine-readable ID, and should hence not contain spaces or anything like that. Good
* examples are: "api-route-handler", "renderPart()", etc.
*
* Errors that bubble up to the top of runAsynchronously or a route handler are already captured with captureError.
*/
export function captureError(location: string, error: unknown): void {
for (const sink of errorSinks) {
sink(

View File

@ -93,7 +93,7 @@ export function ActiveSessionsPage(props?: {
await userFromHook.revokeSession(sessionId);
setSessions(prev => prev.filter(session => session.id !== sessionId));
} catch (error) {
captureError("Failed to revoke session", { sessionId ,error });
captureError("session-revoke", { sessionId ,error });
throw error;
}
};
@ -112,7 +112,7 @@ export function ActiveSessionsPage(props?: {
setSessions(prevSessions => prevSessions.filter(session => session.isCurrentSession));
}
} catch (error) {
captureError("Failed to revoke all sessions", { error, sessionIds: sessions.map(session => session.id) });
captureError("all-sessions-revoke", { error, sessionIds: sessions.map(session => session.id) });
throw error;
} finally {
setIsRevokingAll(false);