Skip to content

Commit

Permalink
#186 wrap bare strings to Error object (#207)
Browse files Browse the repository at this point in the history
Co-authored-by: Arseniy Golushkov <ars@MacBook-Pro-Arseniy.local>
  • Loading branch information
arseniy-gl and Arseniy Golushkov authored Oct 26, 2023
1 parent a27ebd0 commit 7971035
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7971035

Please sign in to comment.