Add some other errors

This commit is contained in:
Eduard Gert
2026-02-05 14:30:55 +01:00
parent 7504e718d7
commit 4433f44a12
10 changed files with 46 additions and 7 deletions

View File

@@ -89,6 +89,8 @@ func getRequestID(r *http.Request) string {
// classifyProxyError determines the appropriate error title, message, HTTP
// status code, and component status based on the error type.
func classifyProxyError(err error) (title, message string, code int, status web.ErrorStatus) {
errStr := err.Error()
switch {
case errors.Is(err, context.DeadlineExceeded):
return "Request Timeout",
@@ -108,16 +110,36 @@ func classifyProxyError(err error) (title, message string, code int, status web.
http.StatusInternalServerError,
web.ErrorStatus{Proxy: false, Peer: false, Destination: false}
case strings.Contains(err.Error(), "connection refused"):
case strings.Contains(errStr, "no peer connection found"),
strings.Contains(errStr, "start netbird client"),
strings.Contains(errStr, "engine not started"),
strings.Contains(errStr, "get net:"):
// The proxy peer (embedded client) is not connected
return "Proxy Not Connected",
"The proxy is not connected to the NetBird network. Please try again later or contact your administrator.",
http.StatusBadGateway,
web.ErrorStatus{Proxy: false, Peer: false, Destination: false}
case strings.Contains(errStr, "connection refused"):
// Routing peer connected but destination service refused the connection
return "Service Unavailable",
"The connection to the service was refused. Please verify that the service is running and try again.",
http.StatusBadGateway,
web.ErrorStatus{Proxy: true, Peer: true, Destination: false}
default:
case strings.Contains(errStr, "no route to host"),
strings.Contains(errStr, "network is unreachable"),
strings.Contains(errStr, "i/o timeout"):
// Peer is not reachable
return "Peer Not Connected",
"The connection to the peer could not be established. Please ensure the peer is running and connected to the NetBird network.",
http.StatusBadGateway,
web.ErrorStatus{Proxy: true, Peer: false, Destination: false}
}
// Unknown error - log it and show generic message
return "Connection Error",
"An unexpected error occurred while connecting to the service. Please try again later.",
http.StatusBadGateway,
web.ErrorStatus{Proxy: true, Peer: false, Destination: false}
}

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

9
proxy/web/dist/assets/index.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

1
proxy/web/dist/assets/style.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -2,12 +2,12 @@
<html lang="en" class="dark">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="/assets/favicon-Cv-2QvSV.ico" />
<link rel="icon" type="image/x-icon" href="/assets/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NetBird Service</title>
<meta name="robots" content="noindex, nofollow" />
<script type="module" crossorigin src="/assets/index-BWSM6sR5.js"></script>
<link rel="stylesheet" crossorigin href="/assets/style-IH-yd16d.css">
<script type="module" crossorigin src="/assets/index.js"></script>
<link rel="stylesheet" crossorigin href="/assets/style.css">
</head>
<body>
<!-- Go template variables injected here -->

View File

@@ -18,7 +18,7 @@ export function ErrorPage({ code, title, message, proxy = true, peer = true, des
<main className="flex flex-col items-center mt-24 px-4 max-w-3xl mx-auto">
{/* Error Code */}
<div className="text-sm text-netbird font-normal font-mono mb-3 z-10 relative">
{code} {title === "Service Unavailable" ? "Bad Gateway" : title.split(" ").slice(0, 2).join(" ")}
Error {code}
</div>
{/* Title */}
@@ -31,7 +31,7 @@ export function ErrorPage({ code, title, message, proxy = true, peer = true, des
<div className="hidden sm:flex items-start justify-center w-full mt-6 mb-16 z-10 relative">
<StatusCard icon={UserIcon} label="You" line={false} />
<StatusCard icon={WaypointsIcon} label="Proxy" success={proxy} />
<StatusCard icon={Server} label="Routing Peer" success={peer} />
<StatusCard icon={Server} label="Peer" success={peer} />
<StatusCard icon={Globe} label="Destination" success={destination} />
</div>

View File

@@ -20,5 +20,12 @@ export default defineConfig({
outDir: 'dist',
assetsDir: 'assets',
cssCodeSplit: false,
rollupOptions: {
output: {
entryFileNames: 'assets/index.js',
chunkFileNames: 'assets/[name].js',
assetFileNames: 'assets/[name][extname]',
},
},
},
})