]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/hashicorp/terraform/registry/errors.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / registry / errors.go
CommitLineData
15c0b25d
AP
1package registry
2
3import (
4 "fmt"
5
6 "github.com/hashicorp/terraform/registry/regsrc"
107c1cdb 7 "github.com/hashicorp/terraform/svchost/disco"
15c0b25d
AP
8)
9
10type errModuleNotFound struct {
11 addr *regsrc.Module
12}
13
14func (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.
21func IsModuleNotFound(err error) bool {
22 _, ok := err.(*errModuleNotFound)
23 return ok
24}
107c1cdb
ND
25
26type errProviderNotFound struct {
27 addr *regsrc.TerraformProvider
28}
29
30func (e *errProviderNotFound) Error() string {
31 return fmt.Sprintf("provider %s not found", e.addr)
32}
33
34// IsProviderNotFound returns true only if the given error is a "provider not found"
35// error. This allows callers to recognize this particular error condition
36// as distinct from operational errors such as poor network connectivity.
37func IsProviderNotFound(err error) bool {
38 _, ok := err.(*errProviderNotFound)
39 return ok
40}
41
42// IsServiceNotProvided returns true only if the given error is a "service not provided"
43// error. This allows callers to recognize this particular error condition
44// as distinct from operational errors such as poor network connectivity.
45func IsServiceNotProvided(err error) bool {
46 _, ok := err.(*disco.ErrServiceNotProvided)
47 return ok
48}
49
50// ServiceUnreachableError Registry service is unreachable
51type ServiceUnreachableError struct {
52 err error
53}
54
55func (e *ServiceUnreachableError) Error() string {
56 return e.err.Error()
57}
58
59// IsServiceUnreachable returns true if the registry/discovery service was unreachable
60func IsServiceUnreachable(err error) bool {
61 _, ok := err.(*ServiceUnreachableError)
62 return ok
63}