Skip to content

Commit

Permalink
Replace errors pkg with fmt.Errorf (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopalet authored Sep 27, 2023
1 parent 168088f commit 64e522c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions templates/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -314,7 +313,7 @@ func (c *APIClient) prepareRequest(
// add form parameters and file if available.
if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) {
if body != nil {
return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
return nil, fmt.Errorf("cannot specify postBody and multipart form at the same time.")
}
body = &bytes.Buffer{}
w := multipart.NewWriter(body)
Expand Down Expand Up @@ -355,7 +354,7 @@ func (c *APIClient) prepareRequest(
if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
if body != nil {
return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.")
return nil, fmt.Errorf("cannot specify postBody and x-www-form-urlencoded form at the same time.")
}
body = &bytes.Buffer{}
body.WriteString(formParams.Encode())
Expand Down Expand Up @@ -521,14 +520,14 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err
return err
}
} else {
return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
return fmt.Errorf("unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
}
} else if err = json.Unmarshal(b, v); err != nil { // simple model
return err
}
return nil
}
return errors.New("undefined response type")
return fmt.Errorf("undefined response type")
}

// Add a file to the multipart request
Expand Down

0 comments on commit 64e522c

Please sign in to comment.