mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-02 11:39:06 +02:00
Consolidate duplicate timeout cases in classifyProxyError
This commit is contained in:
@@ -320,7 +320,8 @@ func getRequestID(r *http.Request) string {
|
|||||||
// status code, and component status based on the error type.
|
// status code, and component status based on the error type.
|
||||||
func classifyProxyError(err error) (title, message string, code int, status web.ErrorStatus) {
|
func classifyProxyError(err error) (title, message string, code int, status web.ErrorStatus) {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, context.DeadlineExceeded):
|
case errors.Is(err, context.DeadlineExceeded),
|
||||||
|
isNetTimeout(err):
|
||||||
return "Request Timeout",
|
return "Request Timeout",
|
||||||
"The request timed out while trying to reach the service. Please refresh the page and try again.",
|
"The request timed out while trying to reach the service. Please refresh the page and try again.",
|
||||||
http.StatusGatewayTimeout,
|
http.StatusGatewayTimeout,
|
||||||
@@ -356,12 +357,6 @@ func classifyProxyError(err error) (title, message string, code int, status web.
|
|||||||
"The connection to the peer could not be established. Please ensure the peer is running and connected to the NetBird network.",
|
"The connection to the peer could not be established. Please ensure the peer is running and connected to the NetBird network.",
|
||||||
http.StatusBadGateway,
|
http.StatusBadGateway,
|
||||||
web.ErrorStatus{Proxy: true, Destination: false}
|
web.ErrorStatus{Proxy: true, Destination: false}
|
||||||
|
|
||||||
case isNetTimeout(err):
|
|
||||||
return "Request Timeout",
|
|
||||||
"The request timed out while trying to reach the service. Please refresh the page and try again.",
|
|
||||||
http.StatusGatewayTimeout,
|
|
||||||
web.ErrorStatus{Proxy: true, Destination: false}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Connection Error",
|
return "Connection Error",
|
||||||
|
|||||||
Reference in New Issue
Block a user