summaryrefslogtreecommitdiff
path: root/pkg/errorhandling/errorhandling.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-01-13 13:29:24 -0500
committerGitHub <noreply@github.com>2021-01-13 13:29:24 -0500
commit2b0cf7728d4cd59d19821a1324a8ac2dcd7d3cac (patch)
treeb681487112bcfb24d8d7b08b2cfe4dfd39addd24 /pkg/errorhandling/errorhandling.go
parent9473dda87c10513527bb083719d642d493b6b356 (diff)
parent827f6c9cb01929a7c36a465d633c82d384ed7ddb (diff)
downloadpodman-2b0cf7728d4cd59d19821a1324a8ac2dcd7d3cac.tar.gz
podman-2b0cf7728d4cd59d19821a1324a8ac2dcd7d3cac.tar.bz2
podman-2b0cf7728d4cd59d19821a1324a8ac2dcd7d3cac.zip
Merge pull request #8954 from baude/reducebindingsize
Reduce general binding binary size
Diffstat (limited to 'pkg/errorhandling/errorhandling.go')
-rw-r--r--pkg/errorhandling/errorhandling.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go
index 21df261fb..b1923be98 100644
--- a/pkg/errorhandling/errorhandling.go
+++ b/pkg/errorhandling/errorhandling.go
@@ -70,3 +70,27 @@ func CloseQuiet(f *os.File) {
func Contains(err error, sub error) bool {
return strings.Contains(err.Error(), sub.Error())
}
+
+// ErrorModel is used in remote connections with podman
+type ErrorModel struct {
+ // API root cause formatted for automated parsing
+ // example: API root cause
+ Because string `json:"cause"`
+ // human error message, formatted for a human to read
+ // example: human error message
+ Message string `json:"message"`
+ // http response code
+ ResponseCode int `json:"response"`
+}
+
+func (e ErrorModel) Error() string {
+ return e.Message
+}
+
+func (e ErrorModel) Cause() error {
+ return errors.New(e.Because)
+}
+
+func (e ErrorModel) Code() int {
+ return e.ResponseCode
+}