Skip to content

Commit 3aac3cd

Browse files
committed
feat: improved error messages
1 parent bedc854 commit 3aac3cd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/util/fetch.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,12 @@ module.exports = async (url, options = {}) => {
2020
},
2121
})
2222
.then((res) => ({ data: res.body }))
23-
.catch((error) => ({ error }));
23+
.catch((error) => {
24+
const { body } = error.response;
25+
26+
if (typeof body == 'object' && body.message)
27+
error.message = body.message;
28+
29+
return { error };
30+
});
2431
};

0 commit comments

Comments
 (0)