fix(grpc): error handling
@@ -138,6 +138,16 @@ func (s *GRPCSignal) Signal(stream pb.SFU_SignalServer) error {
}
answer, err := peer.Answer(offer)
+ if err != nil {
+ switch err {
+ case sfu.ErrNoTransportEstablished:
+ log.Errorf("peer hasn't joined")
+ return status.Errorf(codes.FailedPrecondition, err.Error())
+ default:
+ return status.Errorf(codes.Internal, fmt.Sprintf("negotiate error: %v", err))
+ }
+ }
+
err = stream.Send(&pb.SignalReply{
Payload: &pb.SignalReply_Negotiate{
Negotiate: &pb.SessionDescription{
@@ -146,15 +156,10 @@ func (s *GRPCSignal) Signal(stream pb.SFU_SignalServer) error {
},
},
})
+
if err != nil {
- switch err {
- case sfu.ErrNoTransportEstablished:
- log.Errorf("peer hasn't joined")
- return status.Errorf(codes.FailedPrecondition, err.Error())
- default:
return status.Errorf(codes.Internal, fmt.Sprintf("negotiate error: %v", err))
}
- }
} else if payload.Negotiate.Type == webrtc.SDPTypeAnswer.String() {
answer := webrtc.SessionDescription{
