mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-26 13:39:47 +00:00
e9924fac05
Use observed HTTP status to distinguish authentication rejection, denial and unknown cause. Point to the actual saved connection and attempted endpoint without prescribing a role, mutating ACLs or exposing token identities or provider text. Preserve inventory and setup semantics and privilege separation; cover custom/manual identities and real-client 401/403/proxy producer paths. Contract-Neutral: Correct existing diagnostic guidance and expose only internal HTTP-status evidence; no API shape, collection, inventory, setup permission or guest-safety contract changes. Change-source: pulse-maintainer
18 lines
473 B
Go
18 lines
473 B
Go
package proxmox
|
|
|
|
import "errors"
|
|
|
|
// APIErrorStatus returns the observed HTTP status, never a number quoted in a
|
|
// provider's error body. Unknown/local errors have no HTTP-status evidence.
|
|
func APIErrorStatus(err error) (int, bool) {
|
|
var response *apiResponseError
|
|
if errors.As(err, &response) && response != nil {
|
|
return response.statusCode, true
|
|
}
|
|
var auth *authHTTPError
|
|
if errors.As(err, &auth) && auth != nil {
|
|
return auth.status, true
|
|
}
|
|
return 0, false
|
|
}
|