web/admin: use SentryIgnoredError for user errors

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-21 19:44:44 +01:00
parent 7fb939f97b
commit dad43017a0
5 changed files with 10 additions and 5 deletions

View file

@ -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`);

View file

@ -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<MessageContainer>("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();

View file

@ -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<Flow> {
send = (data: Flow): Promise<void> => {
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,

View file

@ -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<SAMLProvider> {
send = (data: SAMLProvider): Promise<void> => {
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,

View file

@ -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<T>(...args: Array<T | undefined | null>): 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 {