summaryrefslogtreecommitdiff
path: root/pkg/errorhandling/errorhandling.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2021-01-12 13:44:56 -0600
committerbaude <bbaude@redhat.com>2021-01-13 09:35:24 -0600
commit827f6c9cb01929a7c36a465d633c82d384ed7ddb (patch)
tree581ce5889f07b19770bbd9c4ff0dd56ddfc9ea50 /pkg/errorhandling/errorhandling.go
parent99c5746150799d6cfe3ea612d3c88c6b904f9312 (diff)
downloadpodman-827f6c9cb01929a7c36a465d633c82d384ed7ddb.tar.gz
podman-827f6c9cb01929a7c36a465d633c82d384ed7ddb.tar.bz2
podman-827f6c9cb01929a7c36a465d633c82d384ed7ddb.zip
Reduce general binding binary size
when using the bindings to *only* make a connection, the binary was rough 28MB. This PR reduces it down to 11. There is more work to do but it will come in a secondary PR. Signed-off-by: baude <bbaude@redhat.com>
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
+}