We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3e98d13 commit fc11ebaCopy full SHA for fc11eba
src/puter-js/src/lib/RequestError.js
@@ -0,0 +1,6 @@
1
+export class RequestError extends Error {
2
+ constructor (message) {
3
+ super(message);
4
+ this.name = 'RequestError'; // thanks minifier
5
+ }
6
+}
src/puter-js/src/modules/Threads.js
@@ -1,3 +1,5 @@
+import { RequestError } from "../lib/RequestError.js";
+
export default class Threads {
constructor (context) {
this.authToken = context.authToken;
@@ -20,6 +22,12 @@ export default class Threads {
20
22
...(body ? { body: JSON.stringify(body) } : {}),
21
23
}
24
);
25
+ if ( ! resp.ok ) {
26
+ const resp_data = await resp.json();
27
+ const err = new RequestError(resp_data.message);
28
+ err.response = resp_data;
29
+ throw err;
30
31
return await resp.json();
32
33
0 commit comments