summaryrefslogtreecommitdiff
path: root/content/error.njk
blob: 61c45d54789946dcef86a36a16829c804d3a5762 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<h1 id="error-code">Error</h1>
<img src="" id="error-image" style="width: 100%;">

<script>
    const params = new URLSearchParams(window.location.search)
    const code = params.get("code") || "404"

    // yes, i typed these out manually.
    const messages = {
        400: "Bad request",
        401: "Unauthorized",
        402: "Payment required",
        403: "Forbidden",
        404: "Not found",
        405: "Method not allowed",
        406: "Not acceptable",
        407: "Proxy authentication required",
        408: "Request timeout",
        409: "Conflict",
        410: "Gone",
        411: "Length required",
        412: "Precondition failed",
        413: "Payload too large",
        414: "Request-URI too long",
        415: "Unsupported media type",
        416: "Request range not satisfiable",
        417: "Expectation failed",
        418: "I'm a teapot",
        419: "Page expired",
        420: "Enhance your calm",
        421: "Misdirected request",
        422: "Unprocessable entity",
        423: "Locked",
        424: "Failed dependency",
        425: "Too early",
        426: "Upgrade required",
        428: "Precondition Required",
        429: "Too many requests",
        431: "Request header fields too large",
        444: "No response",
        450: "Blocked by windows parental controls",
        451: "Unavailable for legal reasons",
        495: "SSL certificate error",
        496: "SSL certificate required",
        497: "HTTP request sent to HTTPS port",
        498: "Token expired/invalid",
        499: "Client closed request",


        500: "Internal server error",
        501: "Not implemented",
        502: "Bad gateway",
        503: "Service unavailable",
        504: "Gateway timeout",
        506: "Variant also negotiates",
        507: "Insufficient storage",
        508: "Loop detected",
        509: "Bandwidth limit exceeded",
        510: "Not extended",
        511: "Network authentication required",
        521: "Web server is down",
        522: "Connection timed out",
        523: "Origin is unreachable",
        525: "SSL handshake failed",
        530: "Site frozen",
        599: "Network connect timeout error"
    }

    document.getElementById("error-code").textContent = "Error " + code + " - " + (messages[code] || "Unexpected error")
    const host = Math.random() < 0.5 ? "cat" : "dog";
    const url = host === "dog"
        ? `https://http.dog/${code}.jpg`
        : `https://http.cat/${code}`;

    document.getElementById("error-image").src = url;
</script>