From dad43017a000434888865a02dc8beba8b89bdd0d Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 21 Dec 2021 19:44:44 +0100 Subject: [PATCH] web/admin: use SentryIgnoredError for user errors Signed-off-by: Jens Langhammer --- web/src/api/Plex.ts | 3 ++- web/src/elements/messages/MessageContainer.ts | 3 ++- web/src/pages/flows/FlowImportForm.ts | 3 ++- web/src/pages/providers/saml/SAMLProviderImportForm.ts | 3 ++- web/src/utils.ts | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/web/src/api/Plex.ts b/web/src/api/Plex.ts index d619d24e6..fadab730d 100644 --- a/web/src/api/Plex.ts +++ b/web/src/api/Plex.ts @@ -1,3 +1,4 @@ +import { SentryIgnoredError } from "../common/errors"; import { VERSION } from "../constants"; export interface PlexPinResponse { @@ -73,7 +74,7 @@ export class PlexAPIClient { headers: headers, }); if (pinResponse.status > 200) { - throw new Error("Invalid response code") + throw new SentryIgnoredError("Invalid response code") } const pin: PlexPinResponse = await pinResponse.json(); console.debug(`authentik/plex: polling Pin`); diff --git a/web/src/elements/messages/MessageContainer.ts b/web/src/elements/messages/MessageContainer.ts index be2f3e491..c670ffbcf 100644 --- a/web/src/elements/messages/MessageContainer.ts +++ b/web/src/elements/messages/MessageContainer.ts @@ -4,6 +4,7 @@ import { customElement, property } from "lit/decorators.js"; import PFAlertGroup from "@patternfly/patternfly/components/AlertGroup/alert-group.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; +import { SentryIgnoredError } from "../../common/errors"; import { WSMessage } from "../../common/ws"; import { EVENT_WS_MESSAGE, WS_MSG_TYPE_MESSAGE } from "../../constants"; import "./Message"; @@ -12,7 +13,7 @@ import { APIMessage } from "./Message"; export function showMessage(message: APIMessage, unique = false): void { const container = document.querySelector("ak-message-container"); if (!container) { - throw new Error("failed to find message container"); + throw new SentryIgnoredError("failed to find message container"); } container.addMessage(message, unique); container.requestUpdate(); diff --git a/web/src/pages/flows/FlowImportForm.ts b/web/src/pages/flows/FlowImportForm.ts index da4f36fd0..e50ecde4d 100644 --- a/web/src/pages/flows/FlowImportForm.ts +++ b/web/src/pages/flows/FlowImportForm.ts @@ -6,6 +6,7 @@ import { customElement } from "lit/decorators.js"; import { Flow, FlowsApi } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../api/Config"; +import { SentryIgnoredError } from "../../common/errors"; import { Form } from "../../elements/forms/Form"; import "../../elements/forms/HorizontalFormElement"; @@ -19,7 +20,7 @@ export class FlowImportForm extends Form { send = (data: Flow): Promise => { const file = this.getFormFile(); if (!file) { - throw new Error("No form data"); + throw new SentryIgnoredError("No form data"); } return new FlowsApi(DEFAULT_CONFIG).flowsInstancesImportFlowCreate({ file: file, diff --git a/web/src/pages/providers/saml/SAMLProviderImportForm.ts b/web/src/pages/providers/saml/SAMLProviderImportForm.ts index a166e090e..0ed2ebb0b 100644 --- a/web/src/pages/providers/saml/SAMLProviderImportForm.ts +++ b/web/src/pages/providers/saml/SAMLProviderImportForm.ts @@ -12,6 +12,7 @@ import { } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../../api/Config"; +import { SentryIgnoredError } from "../../../common/errors"; import { Form } from "../../../elements/forms/Form"; import "../../../elements/forms/HorizontalFormElement"; @@ -25,7 +26,7 @@ export class SAMLProviderImportForm extends Form { send = (data: SAMLProvider): Promise => { const file = this.getFormFile(); if (!file) { - throw new Error("No form data"); + throw new SentryIgnoredError("No form data"); } return new ProvidersApi(DEFAULT_CONFIG).providersSamlImportMetadataCreate({ file: file, diff --git a/web/src/utils.ts b/web/src/utils.ts index d4102f786..5713acb44 100644 --- a/web/src/utils.ts +++ b/web/src/utils.ts @@ -2,6 +2,7 @@ import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; +import { SentryIgnoredError } from "./common/errors"; import "./elements/EmptyState"; export function getCookie(name: string): string { @@ -73,7 +74,7 @@ export function first(...args: Array): T { return element; } } - throw new Error(`No compatible arg given: ${args}`); + throw new SentryIgnoredError(`No compatible arg given: ${args}`); } export function hexEncode(buf: Uint8Array): string {