Skip to content

Commit

Permalink
Modify the displayed error
Browse files Browse the repository at this point in the history
  • Loading branch information
gfenn-newbury committed Dec 21, 2021
1 parent 4bba076 commit 97edeed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (c *Client) sendRequest(req *http.Request, v interface{}) error {
if res.StatusCode < http.StatusOK || res.StatusCode >= http.StatusBadRequest {
var errRes errorResponse
if err = json.NewDecoder(res.Body).Decode(&errRes); err == nil {
return fmt.Errorf("%s - %s", errRes.Message, errRes.Detail)
return errors.New(errRes.Detail)
}

return fmt.Errorf("unknown error, status code: %d", res.StatusCode)
Expand Down
2 changes: 1 addition & 1 deletion client/interface_bridge_port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestCreateInterfaceBridgePort(t *testing.T) {
c := NewClient(GetCredentialsFromEnvVar())
bridge_port := new(InterfaceBridgePort)
bridge_port.Bridge = "bridge"
bridge_port.Interface = "sfp-sfpplus1"
bridge_port.Interface = "ether2"
bridge_port.Disabled = "false"
bridge_port.Pvid = "10"
res, err := c.CreateInterfaceBridgePort(bridge_port)
Expand Down

0 comments on commit 97edeed

Please sign in to comment.