mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 10:02:33 +08:00
Datasources: Improved network health check error messages (sql datasources) (#97783)
remove unique identifiers from common network error messages
This commit is contained in:
@ -44,7 +44,23 @@ func ErrToHealthCheckResult(err error) (*backend.CheckHealthResult, error) {
|
||||
if errors.As(err, &opErr) {
|
||||
res.Message = "Network error: Failed to connect to the server"
|
||||
if opErr != nil && opErr.Err != nil {
|
||||
res.Message += fmt.Sprintf(". Error message: %s", opErr.Err.Error())
|
||||
errMessage := opErr.Err.Error()
|
||||
if strings.HasSuffix(opErr.Err.Error(), "no such host") {
|
||||
errMessage = "no such host"
|
||||
}
|
||||
if strings.HasSuffix(opErr.Err.Error(), "unknown port") {
|
||||
errMessage = "unknown port"
|
||||
}
|
||||
if strings.HasSuffix(opErr.Err.Error(), "invalid port") {
|
||||
errMessage = "invalid port"
|
||||
}
|
||||
if strings.HasSuffix(opErr.Err.Error(), "missing port in address") {
|
||||
errMessage = "missing port in address"
|
||||
}
|
||||
if strings.HasSuffix(opErr.Err.Error(), "invalid syntax") {
|
||||
errMessage = "invalid syntax found in the address"
|
||||
}
|
||||
res.Message += fmt.Sprintf(". Error message: %s", errMessage)
|
||||
}
|
||||
}
|
||||
if errors.Is(err, pq.ErrSSLNotSupported) {
|
||||
|
Reference in New Issue
Block a user