Skip to content

Commit

Permalink
Create extremely basic error class
Browse files Browse the repository at this point in the history
  • Loading branch information
Regalijan authored Oct 29, 2024
1 parent bc7ba73 commit 0552a5f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/util/apiError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// The data should be a response object

class RobloxAPIError extends Error {
constructor(data) {
this.httpStatusCode = data.statusCode
this.responseBody = (function () {
if (typeof data.body === "string") return data.body;

try {
return JSON.stringify(data.body)
} catch {
throw Error("The passed response body is not a valid object")
}
})
}
}

0 comments on commit 0552a5f

Please sign in to comment.