Skip to content

Commit

Permalink
Changes made in error codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar-kalsi committed Oct 26, 2023
1 parent 2536962 commit e4e2d70
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ func (cs *server) publishHandler(w http.ResponseWriter, r *http.Request, _ httpr
var sensorIDMap map[string]string
// Decode into the sensorDataMap
if err := decoder.Decode(&sensorIDMap); err != nil {
http.Error(w, "JSON decoding error: "+err.Error(), http.StatusBadRequest)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

// Get the sensorID from the map
sensorID, exists := sensorIDMap["sensorID"]
if !exists {
http.Error(w, "Sensor Id does not exists.", http.StatusBadRequest)
http.Error(w, "sensor id does not exists", http.StatusBadRequest)
return
}

if len(sensorID) < 8 {
http.Error(w, "Sensor ID must have at least 8 characters.", http.StatusBadRequest)
http.Error(w, "sensor id must have at least 8 characters", http.StatusBadRequest)
return
}

Expand Down

0 comments on commit e4e2d70

Please sign in to comment.