You've already forked AstralRinth
forked from didirus/AstralRinth
Fix server suspension statuses (#3100)
* chore: correctly type suspension reason Signed-off-by: Evan Song <theevansong@gmail.com> * fix: faulty suspension condition allowing for fallthrough Signed-off-by: Evan Song <theevansong@gmail.com> * fix: here as well Signed-off-by: Evan Song <theevansong@gmail.com> * chore: add support suspension reason Signed-off-by: Evan Song <theevansong@gmail.com> * feat: handle support suspensions Signed-off-by: Evan Song <theevansong@gmail.com> * chore: patch pyroservers to handle 503 Signed-off-by: Evan Song <theevansong@gmail.com> * feat: handle 503 in server root Signed-off-by: Evan Song <theevansong@gmail.com> * chore: dont make pyroservers errors scream at me anymore Signed-off-by: Evan Song <theevansong@gmail.com> --------- Signed-off-by: Evan Song <theevansong@gmail.com>
This commit is contained in:
@@ -67,10 +67,10 @@ async function PyroFetch<T>(path: string, options: PyroFetchOptions = {}): Promi
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("[PYROSERVERS]:", error);
|
||||
console.error("[PyroServers/PyroFetch]:", error);
|
||||
if (error instanceof FetchError) {
|
||||
const statusCode = error.response?.status;
|
||||
const statusText = error.response?.statusText || "Unknown error";
|
||||
const statusText = error.response?.statusText || "[no status text available]";
|
||||
const errorMessages: { [key: number]: string } = {
|
||||
400: "Bad Request",
|
||||
401: "Unauthorized",
|
||||
@@ -80,15 +80,16 @@ async function PyroFetch<T>(path: string, options: PyroFetchOptions = {}): Promi
|
||||
429: "Too Many Requests",
|
||||
500: "Internal Server Error",
|
||||
502: "Bad Gateway",
|
||||
503: "Service Unavailable",
|
||||
};
|
||||
const message =
|
||||
statusCode && statusCode in errorMessages
|
||||
? errorMessages[statusCode]
|
||||
: `HTTP Error: ${statusCode || "unknown"} ${statusText}`;
|
||||
throw new PyroFetchError(`[PYROSERVERS][PYRO] ${message}`, statusCode, error);
|
||||
: `HTTP Error: ${statusCode || "[unhandled status code]"} ${statusText}`;
|
||||
throw new PyroFetchError(`[PyroServers/PyroFetch] ${message}`, statusCode, error);
|
||||
}
|
||||
throw new PyroFetchError(
|
||||
"[PYROSERVERS][PYRO] An unexpected error occurred during the fetch operation.",
|
||||
"[PyroServers/PyroFetch] An unexpected error occurred during the fetch operation.",
|
||||
undefined,
|
||||
error as Error,
|
||||
);
|
||||
@@ -168,7 +169,15 @@ interface General {
|
||||
backup_quota: number;
|
||||
used_backup_quota: number;
|
||||
status: string;
|
||||
suspension_reason: string;
|
||||
suspension_reason:
|
||||
| "moderated"
|
||||
| "paymentfailed"
|
||||
| "cancelled"
|
||||
| "other"
|
||||
| "transferring"
|
||||
| "upgrading"
|
||||
| "support"
|
||||
| (string & {});
|
||||
loader: string;
|
||||
loader_version: string;
|
||||
mc_version: string;
|
||||
|
||||
Reference in New Issue
Block a user