Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions client/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"errors"
"fmt"
"net/http"
"time"
Expand Down Expand Up @@ -28,19 +29,19 @@ func GenericJSONErrorHandling(resp *resty.Response, err error) (*resty.Response,
}
case http.StatusInternalServerError:
if !resty.IsJSONType(resp.Header().Get("Content-Type")) {
return nil, fmt.Errorf("unknown error occurred, check supervisor logs with 'ha supervisor logs'")
return nil, errors.New("unknown error occurred, check supervisor logs with 'ha supervisor logs'")
}
case http.StatusUnauthorized:
if !resty.IsJSONType(resp.Header().Get("Content-Type")) {
return nil, fmt.Errorf("unauthorized: missing or invalid API token")
return nil, errors.New("unauthorized: missing or invalid API token")
}
case http.StatusForbidden:
// Handle both JSON and plain text forbidden responses
if !resty.IsJSONType(resp.Header().Get("Content-Type")) {
return nil, fmt.Errorf("forbidden: insufficient permissions or invalid token")
return nil, errors.New("forbidden: insufficient permissions or invalid token")
}
case http.StatusBadGateway:
return nil, fmt.Errorf("bad gateway: core proxy or ingress service failure")
return nil, errors.New("bad gateway: core proxy or ingress service failure")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
default:
return nil, fmt.Errorf("unexpected server response (status: %d)", resp.StatusCode())
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/docker_options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -45,7 +46,7 @@ docker backend running on your Home Assistant system.`,
if mtu == 0 {
options["mtu"] = nil
} else if mtu < 68 || mtu > 65535 {
helper.PrintError(fmt.Errorf("MTU value must be between 68 and 65535, or 0 to reset"))
helper.PrintError(errors.New("MTU value must be between 68 and 65535, or 0 to reset"))
Comment thread
coderabbitai[bot] marked this conversation as resolved.
ExitWithError = true
return
} else {
Expand Down