Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 4b779e5

Browse files
Alberto MurilloSamuel Ortiz
authored andcommitted
imageservice: Don't hide error in Extract functions
The following functions where returning a decoded result and the error of the decoding operation without checking if the original result contains an error already: func (c CreateResult) Extract() (*Image, error) func (c GetResult) Extract() (*Image, error) func (u UpdateResult) Extract() (*Image, error) Signed-off-by: Alberto Murillo <[email protected]>
1 parent e8e5597 commit 4b779e5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

openstack/imageservice/v2/images/results.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ type CreateResult struct {
7373

7474
// Extract build CreateResults from imput Image
7575
func (c CreateResult) Extract() (*Image, error) {
76+
if c.Err != nil {
77+
return nil, c.Err
78+
}
7679
var image *Image
7780

7881
err := mapstructure.Decode(c.Result.Body, &image)
@@ -91,6 +94,9 @@ type GetResult struct {
9194

9295
// Extract builds GetResult
9396
func (c GetResult) Extract() (*Image, error) {
97+
if c.Err != nil {
98+
return nil, c.Err
99+
}
94100
var image *Image
95101

96102
err := mapstructure.Decode(c.Result.Body, &image)
@@ -104,6 +110,9 @@ type UpdateResult struct {
104110

105111
// Extract builds UpdateResult
106112
func (u UpdateResult) Extract() (*Image, error) {
113+
if u.Err != nil {
114+
return nil, u.Err
115+
}
107116
var image *Image
108117

109118
err := mapstructure.Decode(u.Result.Body, &image)

0 commit comments

Comments
 (0)