Postgres: Improve invalid port specifier error during health check (#105536)

normalize error message in postgres invalid port specifier error
This commit is contained in:
Sriram
2025-05-16 11:51:12 +01:00
committed by GitHub
parent 778563223b
commit fcb1e9c9e5
4 changed files with 26 additions and 3 deletions

View File

@ -81,6 +81,12 @@ func ErrToHealthCheckResult(err error) (*backend.CheckHealthResult, error) {
details["verboseMessage"] = pqErr.Message
}
}
if errors.Is(err, ErrInvalidPortSpecified) {
res.Message = fmt.Sprintf("Connection string error: %s", ErrInvalidPortSpecified.Error())
if unwrappedErr := errors.Unwrap(err); unwrappedErr != nil {
details["verboseMessage"] = unwrappedErr.Error()
}
}
detailBytes, marshalErr := json.Marshal(details)
if marshalErr != nil {
return res, nil