Skip to content

Commit 3eb3092

Browse files
committed
fix: better error reporting
1 parent 4ca4bba commit 3eb3092

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "torrust-index-api-lib",
3-
"version": "0.1.14",
3+
"version": "0.1.15",
44
"description": "Contains API functions for the Torrust project.",
55
"repository": "https://github.com/torrust/torrust-index-types-lib",
66
"license": "MIT",

src/utils/fetch.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ export async function request(path: string, config: RequestInit): Promise<Respon
33
const response = await fetch(request);
44

55
if(!response.ok) {
6-
throw new Error(response.statusText);
6+
const res = await response.json();
7+
8+
throw new Error(res?.error ?? response.statusText);
79
}
810

911
return response;

0 commit comments

Comments
 (0)