github.com/jaredpalmer/terraform@v1.1.0-alpha20210908.0.20210911170307-88705c943a03/internal/registry/errors.go (about) 1 package registry 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform-svchost/disco" 7 "github.com/hashicorp/terraform/internal/registry/regsrc" 8 ) 9 10 type errModuleNotFound struct { 11 addr *regsrc.Module 12 } 13 14 func (e *errModuleNotFound) Error() string { 15 return fmt.Sprintf("module %s not found", e.addr) 16 } 17 18 // IsModuleNotFound returns true only if the given error is a "module not found" 19 // error. This allows callers to recognize this particular error condition 20 // as distinct from operational errors such as poor network connectivity. 21 func IsModuleNotFound(err error) bool { 22 _, ok := err.(*errModuleNotFound) 23 return ok 24 } 25 26 // IsServiceNotProvided returns true only if the given error is a "service not provided" 27 // error. This allows callers to recognize this particular error condition 28 // as distinct from operational errors such as poor network connectivity. 29 func IsServiceNotProvided(err error) bool { 30 _, ok := err.(*disco.ErrServiceNotProvided) 31 return ok 32 } 33 34 // ServiceUnreachableError Registry service is unreachable 35 type ServiceUnreachableError struct { 36 err error 37 } 38 39 func (e *ServiceUnreachableError) Error() string { 40 return e.err.Error() 41 } 42 43 // IsServiceUnreachable returns true if the registry/discovery service was unreachable 44 func IsServiceUnreachable(err error) bool { 45 _, ok := err.(*ServiceUnreachableError) 46 return ok 47 }