Skip to content

Commit

Permalink
Change error code type to avoid integer overflow conversion warning
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Sep 1, 2024
1 parent 4612b0a commit fc5d18f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion server/subsonic/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 281,7 @@ func sendError(w http.ResponseWriter, r *http.Request, err error) {
subErr := mapToSubsonicError(err)
response := newResponse()
response.Status = responses.StatusFailed
response.Error = &responses.Error{Code: int32(subErr.code), Message: subErr.Error()}
response.Error = &responses.Error{Code: subErr.code, Message: subErr.Error()}

sendResponse(w, r, response)
}
Expand Down
4 changes: 2 additions & 2 deletions server/subsonic/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 28,11 @@ func newResponse() *responses.Subsonic {
}

type subError struct {
code int
code int32
messages []interface{}
}

func newError(code int, message ...interface{}) error {
func newError(code int32, message ...interface{}) error {
return subError{
code: code,
messages: message,
Expand Down
20 changes: 10 additions & 10 deletions server/subsonic/responses/errors.go
Original file line number Diff line number Diff line change
@@ -1,17 1,17 @@
package responses

const (
ErrorGeneric = 0
ErrorMissingParameter = 10
ErrorClientTooOld = 20
ErrorServerTooOld = 30
ErrorAuthenticationFail = 40
ErrorAuthorizationFail = 50
ErrorTrialExpired = 60
ErrorDataNotFound = 70
ErrorGeneric int32 = 0
ErrorMissingParameter int32 = 10
ErrorClientTooOld int32 = 20
ErrorServerTooOld int32 = 30
ErrorAuthenticationFail int32 = 40
ErrorAuthorizationFail int32 = 50
ErrorTrialExpired int32 = 60
ErrorDataNotFound int32 = 70
)

var errors = map[int]string{
var errors = map[int32]string{
ErrorGeneric: "A generic error",
ErrorMissingParameter: "Required parameter is missing",
ErrorClientTooOld: "Incompatible Subsonic REST protocol version. Client must upgrade",
Expand All @@ -22,7 22,7 @@ var errors = map[int]string{
ErrorDataNotFound: "The requested data was not found",
}

func ErrorMsg(code int) string {
func ErrorMsg(code int32) string {
if v, found := errors[code]; found {
return v
}
Expand Down

0 comments on commit fc5d18f

Please sign in to comment.