Skip to content

Commit

Permalink
feat: also handle 404 with a response body
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom committed Mar 21, 2024
1 parent cced7ec commit 410dbfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ClientFileProducer(
|
|// NewClient creates a new client based on the provided ClientConfig
|func NewClient(cfg *ClientConfig) (*Client, error) {
|
| userAgent := cfg.UserAgent
| if userAgent == "" {
| userAgent = GetUserAgent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ class GoMethodRenderer(
| }
| return result, nil
""".trimMargin()
} else if (it.second.toInt() == 404) {
// If status code is 404 and has a response body we return a sentinel value
"""
|case ${it.second.toInt()}:
| return ${returnValue}ErrNotFound
""".trimMargin()
} else {
// If status is failure and response body is defined we return the marshalled error
"""
Expand Down

0 comments on commit 410dbfb

Please sign in to comment.