diff options
Diffstat (limited to 'vendor/github.com/mitchellh/packer/builder/oracle/oci/client/error.go')
-rw-r--r-- | vendor/github.com/mitchellh/packer/builder/oracle/oci/client/error.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/mitchellh/packer/builder/oracle/oci/client/error.go b/vendor/github.com/mitchellh/packer/builder/oracle/oci/client/error.go new file mode 100644 index 00000000..a97112f8 --- /dev/null +++ b/vendor/github.com/mitchellh/packer/builder/oracle/oci/client/error.go @@ -0,0 +1,27 @@ +package oci + +import "fmt" + +// APIError encapsulates an error returned from the API +type APIError struct { + Code string `json:"code"` + Message string `json:"message"` +} + +func (e APIError) Error() string { + return fmt.Sprintf("OCI: [%s] '%s'", e.Code, e.Message) +} + +// firstError is a helper function to work out which error to return from calls +// to the API. +func firstError(err error, apiError *APIError) error { + if err != nil { + return err + } + + if apiError != nil && len(apiError.Code) > 0 { + return apiError + } + + return nil +} |