Add HTTP 500 error response for MP4 API

This commit is contained in:
Alexey Khit
2023-04-20 13:16:15 +03:00
parent 79f1dcfea3
commit c07ddb8309
+4
View File
@@ -61,6 +61,7 @@ func handlerKeyframe(w http.ResponseWriter, r *http.Request) {
if err := stream.AddConsumer(cons); err != nil {
log.Error().Err(err).Caller().Send()
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -128,6 +129,7 @@ func handlerMP4(w http.ResponseWriter, r *http.Request) {
if err := stream.AddConsumer(cons); err != nil {
log.Error().Err(err).Caller().Send()
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -138,11 +140,13 @@ func handlerMP4(w http.ResponseWriter, r *http.Request) {
data, err := cons.Init()
if err != nil {
log.Error().Err(err).Caller().Send()
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if _, err = w.Write(data); err != nil {
log.Error().Err(err).Caller().Send()
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}