Skip to content

Commit ce06d4a

Browse files
committed
Updating error frowarding from Transfer failures
1 parent 71d2804 commit ce06d4a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/sip/protocol.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,12 @@ func handleReferNotify(cseq uint32, status int, reason string, referCseq uint32,
375375
Code: livekit.SIPStatusCode(status),
376376
Status: reason,
377377
}
378-
result = psrpc.NewErrorf(psrpc.Canceled, "call transfer failed: %w", st)
378+
psrpcErrCode := psrpc.UpstreamServerError
379+
if status < 500 || status >= 600 {
380+
// Common 6xx codes: 603 Declined, 608 Rejected
381+
psrpcErrCode = psrpc.UpstreamClientError
382+
}
383+
result = psrpc.NewErrorf(psrpcErrCode, "call transfer failed: %w", st)
379384
}
380385
select {
381386
case referDone <- result:
@@ -413,6 +418,10 @@ func sipStatusForErrorCode(code psrpc.ErrorCode) sip.StatusCode {
413418
return sip.StatusServiceUnavailable
414419
case psrpc.Unauthenticated:
415420
return sip.StatusUnauthorized
421+
case psrpc.UpstreamServerError:
422+
return sip.StatusBadGateway
423+
case psrpc.UpstreamClientError:
424+
return sip.StatusTemporarilyUnavailable
416425
default:
417426
return sip.StatusInternalServerError
418427
}

0 commit comments

Comments
 (0)