#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-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,

View File

@ -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;
}