aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/connecterror.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-11-24 17:24:00 +0100
committerbptato <nincsnevem662@gmail.com>2024-11-24 17:24:00 +0100
commite10fab72faa22b1eb17206bc13cc518f9fde7c26 (patch)
tree079ef7ea9abe4b01e25be9f662f07ca884c6642f /src/server/connecterror.nim
parent104569343acf8922751578ab4ff41bf003ad1147 (diff)
downloadchawan-e10fab72faa22b1eb17206bc13cc518f9fde7c26.tar.gz
loader/* -> server
one less mystery
Diffstat (limited to 'src/server/connecterror.nim')
-rw-r--r--src/server/connecterror.nim72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/server/connecterror.nim b/src/server/connecterror.nim
new file mode 100644
index 00000000..5b428526
--- /dev/null
+++ b/src/server/connecterror.nim
@@ -0,0 +1,72 @@
+type ConnectionError* = enum
+ ceCGICachedBodyUnavailable = -18
+ ceCGIOutputHandleNotFound = -17
+ ceCGIFailedToOpenCacheOutput = -16
+ ceCGICachedBodyNotFound = -15
+ ceFailedToRedirect = -14
+ ceURLNotInCache = -13
+ ceFileNotInCache = -12
+ ceFailedToExecuteCGIScript = -11
+ ceCGIMalformedHeader = -10
+ ceCGIInvalidChaControl = -9
+ ceTooManyRewrites = -8
+ ceInvalidURIMethodEntry = -7
+ ceCGIFileNotFound = -6
+ ceInvalidCGIPath = -5
+ ceFailedToSetUpCGI = -4
+ ceNoCGIDir = -3
+ ceDisallowedURL = -2
+ ceUnknownScheme = -1
+ ceNone = 0
+ ceInternalError = (1, "InternalError")
+ ceInvalidMethod = (2, "InvalidMethod")
+ ceInvalidURL = (3, "InvalidURL")
+ ceFileNotFound = (4, "FileNotFound")
+ ceConnectionRefused = (5, "ConnectionRefused")
+ ceProxyRefusedToConnect = (6, "ProxyRefusedToConnect")
+ ceFailedToResolveHost = (7, "FailedToResolveHost")
+ ceFailedToResolveProxy = (8, "FailedToResolveProxy")
+ ceProxyAuthFail = (9, "ProxyAuthFail")
+ ceInvalidResponse = (10, "InvalidResponse")
+ ceProxyInvalidResponse = (11, "ProxyInvalidResponse")
+
+const ErrorMessages* = [
+ ceCGICachedBodyUnavailable: "request body is not ready in the cache",
+ ceCGIOutputHandleNotFound: "request body output handle not found",
+ ceCGIFailedToOpenCacheOutput: "failed to open cache output",
+ ceCGICachedBodyNotFound: "cached request body not found",
+ ceFailedToRedirect: "failed to redirect request body",
+ ceURLNotInCache: "URL was not found in the cache",
+ ceFileNotInCache: "file was not found in the cache",
+ ceFailedToExecuteCGIScript: "failed to execute CGI script",
+ ceCGIMalformedHeader: "CGI script returned a malformed header",
+ ceCGIInvalidChaControl: "CGI got invalid Cha-Control header",
+ ceTooManyRewrites: "too many URI method map rewrites",
+ ceInvalidURIMethodEntry: "invalid URI method entry",
+ ceCGIFileNotFound: "CGI file not found",
+ ceInvalidCGIPath: "invalid CGI path",
+ ceFailedToSetUpCGI: "failed to set up CGI script",
+ ceNoCGIDir: "no local-CGI directory configured",
+ ceDisallowedURL: "url not allowed by filter",
+ ceUnknownScheme: "unknown scheme",
+ ceNone: "connection successful",
+ ceInternalError: "internal error",
+ ceInvalidMethod: "invalid method",
+ ceInvalidURL: "invalid URL",
+ ceFileNotFound: "file not found",
+ ceConnectionRefused: "connection refused",
+ ceProxyRefusedToConnect: "proxy refused to connect",
+ ceFailedToResolveHost: "failed to resolve host",
+ ceFailedToResolveProxy: "failed to resolve proxy",
+ ceProxyAuthFail: "proxy authentication failed",
+ ceInvalidResponse: "received an invalid response",
+ ceProxyInvalidResponse: "proxy returned an invalid response",
+]
+
+converter toInt*(code: ConnectionError): int =
+ return int(code)
+
+func getLoaderErrorMessage*(code: int): string =
+ if code in int(ConnectionError.low)..int(ConnectionError.high):
+ return ErrorMessages[ConnectionError(code)]
+ return "unexpected error code " & $code