Skip to content

Commit dd8783a

Browse files
committed
Docstring for captureError
1 parent 343ae8d commit dd8783a

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

apps/backend/src/oauth/model.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class OAuthModel implements AuthorizationCodeModel {
5656
({ domain, handler_path }) => new URL(handler_path, domain).toString()
5757
);
5858
} catch (e) {
59-
captureError("get redirect uris", {
59+
captureError("get-oauth-redirect-urls", {
6060
error: e,
6161
projectId: tenancy.project.id,
6262
domains: tenancy.config.domains,

packages/stack-shared/src/utils/errors.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ registerErrorSink((location, error, ...extraArgs) => {
112112
globalVar.stackCapturedErrors.push({ location, error, extraArgs });
113113
});
114114

115+
/**
116+
* Captures an error and sends it to the error sinks (most notably, Sentry). Errors caught with captureError are
117+
* supposed to be seen by an engineer, so they should be actionable and important.
118+
*
119+
* The location string is a machine-readable ID, and should hence not contain spaces or anything like that. Good
120+
* examples are: "api-route-handler", "renderPart()", etc.
121+
*
122+
* Errors that bubble up to the top of runAsynchronously or a route handler are already captured with captureError.
123+
*/
115124
export function captureError(location: string, error: unknown): void {
116125
for (const sink of errorSinks) {
117126
sink(

packages/template/src/components-page/account-settings/active-sessions/active-sessions-page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function ActiveSessionsPage(props?: {
9393
await userFromHook.revokeSession(sessionId);
9494
setSessions(prev => prev.filter(session => session.id !== sessionId));
9595
} catch (error) {
96-
captureError("Failed to revoke session", { sessionId ,error });
96+
captureError("session-revoke", { sessionId ,error });
9797
throw error;
9898
}
9999
};
@@ -112,7 +112,7 @@ export function ActiveSessionsPage(props?: {
112112
setSessions(prevSessions => prevSessions.filter(session => session.isCurrentSession));
113113
}
114114
} catch (error) {
115-
captureError("Failed to revoke all sessions", { error, sessionIds: sessions.map(session => session.id) });
115+
captureError("all-sessions-revoke", { error, sessionIds: sessions.map(session => session.id) });
116116
throw error;
117117
} finally {
118118
setIsRevokingAll(false);

0 commit comments

Comments
 (0)