mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-14 19:38:40 -05:00
fix: puter.js threads error handling
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
export class RequestError extends Error {
|
||||
constructor (message) {
|
||||
super(message);
|
||||
this.name = 'RequestError'; // thanks minifier
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
...(body ? { body: JSON.stringify(body) } : {}),
|
||||
}
|
||||
);
|
||||
if ( ! resp.ok ) {
|
||||
const resp_data = await resp.json();
|
||||
const err = new RequestError(resp_data.message);
|
||||
err.response = resp_data;
|
||||
throw err;
|
||||
}
|
||||
return await resp.json();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user