Feature Request: Use the Error class instead of strings for errors
Closed this issue · 1 comments
Akeboshiwind commented
For example here.
This could be replaced like so:
diff --git a/src/util.js b/src/util.js
index 40aec78..351b14b 100644
--- a/src/util.js
+++ b/src/util.js
@@ -43,7 +43,7 @@ module.exports = {
let payload = "";
let contentType = res.headers["content-type"];
- if (res.statusCode == 503 || res.statusCode == 502 || res.statusCode == 403) reject(`MangaDex is currently in DDOS mitigation mode. (Status code ${res.statusCode})`);
+ if (res.statusCode == 503 || res.statusCode == 502 || res.statusCode == 403) reject(new Error(`MangaDex is currently in DDOS mitigation mode. (Status code ${res.statusCode})`));^M
else if (res.statusCode >= 500) reject(`MangaDex is currently unavailable. (Status code ${res.statusCode})`);
else if (res.statusCode == 404) {
if (contentType.indexOf("json") == -1) reject("Page not found or the mangadex.org domain is unavailable. (Status code 404)");
If you use a string as an error you don't get useful things like a stack trace to know where the error occurred. This made things really difficult when I was trying to debug #28 😢
md-y commented
Implemented in 4.3.1