github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/provider/openstack/errors.go (about)

     1  // Copyright 2018 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package openstack
     5  
     6  import (
     7  	gooseerrors "github.com/go-goose/goose/v5/errors"
     8  	"github.com/juju/errors"
     9  
    10  	"github.com/juju/juju/environs/context"
    11  	"github.com/juju/juju/provider/common"
    12  )
    13  
    14  // handleCredentialError wraps the common handler,
    15  // passing the Openstack-specific auth failure detection.
    16  func handleCredentialError(err error, ctx context.ProviderCallContext) {
    17  	common.HandleCredentialError(IsAuthorisationFailure, err, ctx)
    18  }
    19  
    20  // IsAuthorisationFailure determines if the given error has an
    21  // authorisation failure.
    22  func IsAuthorisationFailure(err error) bool {
    23  	// This should cover most cases.
    24  	return gooseerrors.IsUnauthorised(errors.Cause(err))
    25  }