diff --git a/.eslintrc.json b/.eslintrc.json index 1c56407..05f67a7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -30,7 +30,7 @@ "no-duplicate-imports": 0, "no-extra-parens": 0, "no-return-assign": 0, - "no-throw-literal": 0, + "no-throw-literal": 1, "no-trailing-spaces": 0, "no-unused-expressions": 0, "no-useless-constructor": 0, diff --git a/src/http.ts b/src/http.ts index 67d293d..6589ba4 100644 --- a/src/http.ts +++ b/src/http.ts @@ -1471,11 +1471,11 @@ export class LemmyHttp { try { json = await response.json(); } catch (error) { - throw response.statusText; + throw new Error(response.statusText); } if (!response.ok) { - throw json["error"] ?? response.statusText; + throw new Error(json["error"] ?? response.statusText); } else { return json; }