diff --git a/packages/client/components/i18n/errors.ts b/packages/client/components/i18n/errors.ts
index 86a27cbe4..ae7ea9c1f 100644
--- a/packages/client/components/i18n/errors.ts
+++ b/packages/client/components/i18n/errors.ts
@@ -1,6 +1,8 @@
import { useLingui } from "@lingui-solid/solid/macro";
import { API } from "stoat.js";
+const RE_BREAK = /\s*\n\s*/g;
+
/**
* Translate any error
*/
@@ -159,6 +161,13 @@ export function useError() {
) {
const message = (error as { message: string }).message.trim();
if (message) return message;
+ } else if (typeof error === "string") {
+ //Strip HTML from string
+ const p = document.createElement("html");
+ p.innerHTML = error;
+ p.querySelector("head")?.remove();
+ p.querySelector("[role=contentinfo]")?.remove();
+ error = p.textContent.trim().replace(RE_BREAK, ". ");
}
return t`Something went wrong! ${error}`;
diff --git a/packages/client/components/modal/modals/Error2.tsx b/packages/client/components/modal/modals/Error2.tsx
index 3f80151ac..3eb44cc10 100644
--- a/packages/client/components/modal/modals/Error2.tsx
+++ b/packages/client/components/modal/modals/Error2.tsx
@@ -1,4 +1,5 @@
import { Trans } from "@lingui-solid/solid/macro";
+import { styled } from "styled-system/jsx";
import { useError } from "@revolt/i18n";
import { Dialog, DialogProps, iconSize } from "@revolt/ui";
@@ -7,6 +8,12 @@ import MdError from "@material-design-icons/svg/outlined/error.svg?component-sol
import { Modals } from "../types";
+const Error = styled("div", {
+ base: {
+ whiteSpace: "pre-wrap",
+ },
+});
+
export function Error2Modal(props: DialogProps & Modals & { type: "error2" }) {
const err = useError();
@@ -18,7 +25,7 @@ export function Error2Modal(props: DialogProps & Modals & { type: "error2" }) {
title={An error occurred.}
actions={[{ text: OK }]}
>
- {err(props.error)}
+ {err(props.error)}
);
}