Change error code type to avoid integer overflow conversion warning

This commit is contained in:
Deluan 2024-09-01 14:41:21 -04:00
parent 4612b0a518
commit fc5d18feb7
3 changed files with 13 additions and 13 deletions

View file

@ -281,7 +281,7 @@ func sendError(w http.ResponseWriter, r *http.Request, err error) {
subErr := mapToSubsonicError(err) subErr := mapToSubsonicError(err)
response := newResponse() response := newResponse()
response.Status = responses.StatusFailed 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) sendResponse(w, r, response)
} }

View file

@ -28,11 +28,11 @@ func newResponse() *responses.Subsonic {
} }
type subError struct { type subError struct {
code int code int32
messages []interface{} messages []interface{}
} }
func newError(code int, message ...interface{}) error { func newError(code int32, message ...interface{}) error {
return subError{ return subError{
code: code, code: code,
messages: message, messages: message,

View file

@ -1,17 +1,17 @@
package responses package responses
const ( const (
ErrorGeneric = 0 ErrorGeneric int32 = 0
ErrorMissingParameter = 10 ErrorMissingParameter int32 = 10
ErrorClientTooOld = 20 ErrorClientTooOld int32 = 20
ErrorServerTooOld = 30 ErrorServerTooOld int32 = 30
ErrorAuthenticationFail = 40 ErrorAuthenticationFail int32 = 40
ErrorAuthorizationFail = 50 ErrorAuthorizationFail int32 = 50
ErrorTrialExpired = 60 ErrorTrialExpired int32 = 60
ErrorDataNotFound = 70 ErrorDataNotFound int32 = 70
) )
var errors = map[int]string{ var errors = map[int32]string{
ErrorGeneric: "A generic error", ErrorGeneric: "A generic error",
ErrorMissingParameter: "Required parameter is missing", ErrorMissingParameter: "Required parameter is missing",
ErrorClientTooOld: "Incompatible Subsonic REST protocol version. Client must upgrade", ErrorClientTooOld: "Incompatible Subsonic REST protocol version. Client must upgrade",
@ -22,7 +22,7 @@ var errors = map[int]string{
ErrorDataNotFound: "The requested data was not found", ErrorDataNotFound: "The requested data was not found",
} }
func ErrorMsg(code int) string { func ErrorMsg(code int32) string {
if v, found := errors[code]; found { if v, found := errors[code]; found {
return v return v
} }