Skip to content

Commit

Permalink
fix: handle error
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Oct 21, 2023
1 parent 0161bcb commit 40e7409
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/waku/server/rest/lightpush_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (serv *LightpushService) postMessagev1(w http.ResponseWriter, req *http.Req

if err := msg.Check(); err != nil {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error()))
_, err = w.Write([]byte(err.Error()))
serv.log.Error("writing response", zap.Error(err))
return
}
//
Expand All @@ -67,7 +68,8 @@ func (serv *LightpushService) postMessagev1(w http.ResponseWriter, req *http.Req
_, err := serv.node.Lightpush().Publish(req.Context(), msg.Message, lightpush.WithPubSubTopic(msg.PubSubTopic))
if err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
w.Write([]byte(err.Error()))
_, err = w.Write([]byte(err.Error()))
serv.log.Error("writing response", zap.Error(err))
} else {
w.WriteHeader(http.StatusOK)
}
Expand Down

0 comments on commit 40e7409

Please sign in to comment.