Fix errors output for webrtc client and server

This commit is contained in:
Alex X
2024-06-16 06:37:42 +03:00
parent 734393d638
commit 31e57c2ff8
2 changed files with 9 additions and 2 deletions
+8 -2
View File
@@ -77,10 +77,15 @@ func go2rtcClient(url string) (core.Producer, error) {
// 2. Create PeerConnection
pc, err := PeerConnection(true)
if err != nil {
log.Error().Err(err).Caller().Send()
return nil, err
}
defer func() {
if err != nil {
_ = pc.Close()
}
}()
// waiter will wait PC error or WS error or nil (connection OK)
var connState core.Waiter
var connMu sync.Mutex
@@ -133,7 +138,8 @@ func go2rtcClient(url string) (core.Producer, error) {
}
if msg.Type != "webrtc/answer" {
return nil, errors.New("wrong answer: " + msg.Type)
err = errors.New("wrong answer: " + msg.String())
return nil, err
}
answer := msg.String()
+1
View File
@@ -65,6 +65,7 @@ func outputWebRTC(w http.ResponseWriter, r *http.Request) {
url := r.URL.Query().Get("src")
stream := streams.Get(url)
if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound)
return
}