fix: #66 non generic api error handling
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 13s
CI Workflow / CI run tests (pull_request) Failing after 27m51s
CI Workflow / CI run build and linting (pull_request) Successful in 31m47s
CI Workflow / Code coverage report (pull_request) Successful in 6s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 50m20s

This commit is contained in:
Marcel_Henselin 2026-02-16 10:19:29 +01:00
parent 43223f5d1f
commit 11611907bc

View file

@ -85,7 +85,17 @@ func CreateInstanceWaitHandler(
func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) {
s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId)
if err != nil {
return false, nil, err
var oapiErr *oapierror.GenericOpenAPIError
ok := errors.As(err, &oapiErr)
if !ok {
return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError: %w", err)
}
switch oapiErr.StatusCode {
case http.StatusNotFound:
return false, nil, nil
default:
return false, nil, fmt.Errorf("api error: %w", err)
}
}
if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
return false, nil, nil