Last active
November 24, 2023 22:41
-
-
Save treuks/18236151e9e85c0cebbb0337473e8cc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const main = () => { | |
const httpCode = JSON.parse(args[0]) | |
if ( !Number.isInteger(httpCode)) { | |
return "Provided arg is not an integer." | |
} | |
if (httpCode < 200) { | |
return "Unstandard error" | |
} | |
if (httpCode > 600) { | |
return "Unstandard error, may be a cloudflare one: https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-1xxx-errors/" | |
} | |
if (httpCode > 1500) { | |
return "Unstandard error, may be a cloudflare one: https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-10xxx-errors/" | |
} | |
switch(httpCode) { | |
case 200: | |
return "Ok" | |
case 201: | |
return "Created" | |
case 202: | |
return "Accepted" | |
case 203: | |
return "Non-Authoritative Information" | |
case 204: | |
return "No content" | |
case 205: | |
return "Reset content" | |
case 206: | |
return "Partial content" | |
case 207: | |
return "Multi-Status" | |
case 208: | |
return "Already reported" | |
case 226: | |
return "IM Used" | |
case 300: | |
return "Multiple choices" | |
case 301: | |
return "Moved permanently" | |
case 302: | |
return "Found" | |
case 303: | |
return "See other" | |
case 304: | |
return "Not modified" | |
case 307: | |
return "Temporary redirect" | |
case 308: | |
return "Permanent redirect" | |
case 400: | |
return "Bad request" | |
case 401: | |
return "Unauthorized" | |
case 402: | |
return "Payment required" | |
case 403: | |
return "Forbidden" | |
case 404: | |
return "Not found" | |
case 405: | |
return "Method not allowed" | |
case 406: | |
return "Not acceptable" | |
case 407: | |
return "Proxy authentication required" | |
case 408: | |
return "Request timeout" | |
case 409: | |
return "Conflict" | |
case 410: | |
return "Gone" | |
case 411: | |
return "Length required" | |
case 412: | |
return "Precondition failed" | |
case 413: | |
return "Payload too large" | |
case 414: | |
return "URI too large" | |
case 415: | |
return "Unsupported media type" | |
case 416: | |
return "Range not satisfiable" | |
case 417: | |
return "Expectation failed" | |
case 418: | |
return "I'm a teapot TeaTime" | |
case 421: | |
return "Misdirected redirect" | |
case 422: | |
return "Unprocessable content" | |
case 423: | |
return "Locked" | |
case 424: | |
return "Failed dependancy" | |
case 425: | |
return "Too early" | |
case 426: | |
return "Upgrade required" | |
case 428: | |
return "Precondition required" | |
case 429: | |
return "Too many requests" | |
case 431: | |
return "Request header fields too large" | |
case 451: | |
return "Unavailable for legal reasons" | |
case 500: | |
return "Internal server error" | |
case 501: | |
return "Not implemented" | |
case 502: | |
return "Bad gateway" | |
case 503: | |
return "Service unavailable" | |
case 504: | |
return "Gateway timeout" | |
case 505: | |
return "HTTP version not supported" | |
case 506: | |
return "Variant also negotiates" | |
case 507: | |
return "Insufficient storage" | |
case 508: | |
return "Loop detected" | |
case 510: | |
return "Not extended" | |
case 511: | |
return "Network authentication required" | |
// Cloudflare errors | |
case 520: | |
return "Cloudflare error: Web server returned an unknown error" | |
case 521: | |
return "Cloudflare error: Web server is down" | |
case 522: | |
return "Cloudflare error: Connection timed out" | |
case 523: | |
return "Cloudflare error: Origin is unreachable" | |
case 524: | |
return "Cloudflare error: A timeout occured" | |
case 525: | |
return "Cloudflare error: SSL handshake failed" | |
case 526: | |
return "Cloudflare error: Invalid SSL certificate" | |
case 527: | |
return "Cloudflare error: Railgun Listener to origin error" | |
case 530: | |
return "Cloudflare error: HTTP error 530 is returned with an accompanying 1XXX error displayed. Search for the specific 1XXX error for troubleshooting information." | |
default: | |
return "Unstandard error." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment