Skip to content

Commit 80e3f54

Browse files
committed
Adding explicit call to psrpc.GetErrorCode(), only then overwriting it
1 parent 4013400 commit 80e3f54

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/sip/protocol.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,16 @@ func handleReferNotify(cseq uint32, status int, reason string, referCseq uint32,
375375
Code: livekit.SIPStatusCode(status),
376376
Status: reason,
377377
}
378-
psrpcErrCode := psrpc.UpstreamServerError
379-
if status < 500 || status >= 600 {
380-
// Common 6xx codes: 603 Declined, 608 Rejected
381-
psrpcErrCode = psrpc.UpstreamClientError
378+
// Converts SIP status to GRPC via SIPStatus.GRPCStatus(), then converts to psrpc via ErrorCodeFromGRPC()
379+
errorCode, _ := psrpc.GetErrorCode(st)
380+
if errorCode == psrpc.Internal || errorCode == psrpc.Unavailable {
381+
// Temporarily overwrite the code until we support a direct SIPStatus -> psrpc.ErrorCode conversion
382+
errorCode = psrpc.UpstreamServerError
383+
if status < 500 || status >= 600 { // Common 6xx codes: 603 Declined, 608 Rejected
384+
errorCode = psrpc.UpstreamClientError
385+
}
382386
}
383-
result = psrpc.NewErrorf(psrpcErrCode, "call transfer failed: %w", st)
387+
result = psrpc.NewErrorf(errorCode, "call transfer failed: %w", st)
384388
}
385389
select {
386390
case referDone <- result:

0 commit comments

Comments
 (0)