0 | module HTTP.API.Client.I18n.EN
 1 |
 2 | import HTTP.API.Client
 3 | import HTTP.I18n.EN
 4 | import public HTTP.API.Client.I18n
 5 |
 6 | %default total
 7 |
 8 | serverErr : Bits16 -> String
 9 | serverErr s =
10 |   """
11 |   The server responded with status code \{show s}. This is a
12 |   server-side error. Please try again in a moment. If this does not
13 |   help, please get in touch with your server admin.
14 |   """
15 |
16 | parameters {auto lg : Logger JS}
17 |   ||| Please note that this is an opinionated implementation of `JSLocal`.
18 |   export
19 |   JSLocal where
20 |     logJSErr x    =
21 |       error
22 |         """
23 |         An error occurred in the user interface. This is probably a bug.
24 |
25 |         Error details: \{dispErr x}
26 |         """
27 |
28 |     logHTTPErr Timeout         =
29 |       error
30 |         """
31 |         Connection to the server timed out. That can happen when you are
32 |         on a slow connection or the server is busy with other requests. If
33 |         the situation does not improve, please get in touch with your
34 |         server admin.
35 |         """
36 |     logHTTPErr NetworkError    =
37 |       error
38 |       """
39 |       Error when connecting to the server. Please check your network
40 |       connection and whether your VPN is correctly set up (if necessary). If this
41 |       does not help, the server might be down. In that case, please
42 |       get in touch with your server admin.
43 |       """
44 |     logHTTPErr (ReqError m)   =
45 |       case cast {to = Bits16} m.status of
46 |         403 => warn m.message
47 |         401 => warn m.message
48 |         409 => warn m.message
49 |         s   => if s >= 500
50 |           then error (serverErr s)
51 |           else
52 |             error
53 |               """
54 |               The server responded with status code \{show m.status}, which is
55 |               unexpected and might be a bug. Please get in touch with your server admin
56 |               and send them the following detailed error message:
57 |               \{m}
58 |               """
59 |     logHTTPErr (DecError s x) =
60 |       if s >= 500 then error (serverErr s)
61 |       else case x of
62 |         ContentErr t d => error
63 |           """
64 |           I got an error when decoding a response from the server. This is
65 |           a bug. Please inform your server admin and send them the error
66 |           message printed below:
67 |           \{t}
68 |           \{d}
69 |           """
70 |         x => error
71 |           """
72 |           I got an error when decoding a response from the server. This is
73 |           a bug. Please inform your server admin and send them the error
74 |           message printed below:
75 |           \{x}
76 |           """
77 |