#186 wrap bare strings to Error object (#207)

Co-authored-by: Arseniy Golushkov <ars@MacBook-Pro-Arseniy.local>
This commit is contained in:
ArseniyGl 2023-10-26 18:56:24 +03:00 committed by GitHub
parent a27ebd024b
commit 79710354bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -30,7 +30,7 @@
"no-duplicate-imports": 0, "no-duplicate-imports": 0,
"no-extra-parens": 0, "no-extra-parens": 0,
"no-return-assign": 0, "no-return-assign": 0,
"no-throw-literal": 0, "no-throw-literal": 1,
"no-trailing-spaces": 0, "no-trailing-spaces": 0,
"no-unused-expressions": 0, "no-unused-expressions": 0,
"no-useless-constructor": 0, "no-useless-constructor": 0,

View file

@ -1471,11 +1471,11 @@ export class LemmyHttp {
try { try {
json = await response.json(); json = await response.json();
} catch (error) { } catch (error) {
throw response.statusText; throw new Error(response.statusText);
} }
if (!response.ok) { if (!response.ok) {
throw json["error"] ?? response.statusText; throw new Error(json["error"] ?? response.statusText);
} else { } else {
return json; return json;
} }