Skip to content

Commit

Permalink
Don't panic if FetchReplications gets a url.Error (#141)
Browse files Browse the repository at this point in the history
If FetchHTTP() suffers a lower-level error, it will return an err that
*is not* an instance of APIError. In such cases, the daemon currently
panics, which isn't a great response. Instead, it should properly handle
the error up the stack and retry later.
  • Loading branch information
epall authored May 23, 2024
1 parent 2850302 commit 56a1722
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion artifactory/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package artifactory

import (
"encoding/json"
"errors"
"fmt"
)

Expand Down Expand Up @@ -39,7 +40,8 @@ func (c *Client) FetchReplications() (Replications, error) {
c.logger.Debug("Fetching replications stats")
resp, err := c.FetchHTTP(replicationEndpoint)
if err != nil {
if err.(*APIError).status == 404 {
var apiErr *APIError
if errors.As(err, &apiErr) && apiErr.status == 404 {
return replications, nil
}
return replications, err
Expand Down

0 comments on commit 56a1722

Please sign in to comment.