Skip to content

Commit

Permalink
Fix error message when unimplemented method is invoked (DiceDB#1078)
Browse files Browse the repository at this point in the history
  • Loading branch information
apatniv authored Oct 14, 2024
1 parent 2d1ec2e commit 97e435c
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions internal/server/httpServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,14 @@ func (s *HTTPServer) DiceHTTPHandler(writer http.ResponseWriter, request *http.R
}

if unimplementedCommands[diceDBCmd.Cmd] {
responseJSON, _ := json.Marshal(utils.HTTPResponse{Status: utils.HTTPStatusError, Data: "Command is not implemented with HTTP"})
responseJSON, _ := json.Marshal(utils.HTTPResponse{Status: utils.HTTPStatusError, Data: fmt.Sprintf("Command %s is not implemented with HTTP", diceDBCmd.Cmd)})
writer.Header().Set("Content-Type", "application/json")
writer.WriteHeader(http.StatusBadRequest) // Set HTTP status code to 500
_, err = writer.Write(responseJSON)
if err != nil {
s.logger.Error("Error writing response", "error", err)
}
s.logger.Error("Command %s is not implemented", slog.String("cmd", diceDBCmd.Cmd))
_, err := writer.Write([]byte("Command is not implemented with HTTP"))
if err != nil {
s.logger.Error("Error writing response", slog.Any("error", err))
return
}
return
}

Expand Down

0 comments on commit 97e435c

Please sign in to comment.