@@ -16,8 +16,6 @@ package sip
16
16
17
17
import (
18
18
"context"
19
- "errors"
20
- "fmt"
21
19
"log/slog"
22
20
"net/netip"
23
21
"strings"
@@ -31,6 +29,7 @@ import (
31
29
"github.com/livekit/protocol/logger"
32
30
"github.com/livekit/protocol/rpc"
33
31
"github.com/livekit/protocol/tracer"
32
+ "github.com/livekit/psrpc"
34
33
"github.com/livekit/sipgo"
35
34
"github.com/livekit/sipgo/sip"
36
35
@@ -132,25 +131,25 @@ func (c *Client) createSIPParticipant(ctx context.Context, req *rpc.InternalCrea
132
131
return nil , siperrors .ErrUnavailable
133
132
}
134
133
if req .CallTo == "" {
135
- return nil , fmt . Errorf ( "call-to number must be set" )
134
+ return nil , psrpc . NewErrorf ( psrpc . InvalidArgument , "call-to number must be set" )
136
135
} else if req .Address == "" {
137
- return nil , fmt . Errorf ( "trunk adresss must be set" )
136
+ return nil , psrpc . NewErrorf ( psrpc . InvalidArgument , "trunk adresss must be set" )
138
137
} else if req .Number == "" {
139
- return nil , fmt . Errorf ( "trunk outbound number must be set" )
138
+ return nil , psrpc . NewErrorf ( psrpc . InvalidArgument , "trunk outbound number must be set" )
140
139
} else if req .RoomName == "" {
141
- return nil , fmt . Errorf ( "room name must be set" )
140
+ return nil , psrpc . NewErrorf ( psrpc . InvalidArgument , "room name must be set" )
142
141
}
143
142
if strings .Contains (req .CallTo , "@" ) {
144
- return nil , errors . New ( "call_to should be a phone number or SIP user, not a full SIP URI" )
143
+ return nil , psrpc . NewErrorf ( psrpc . InvalidArgument , "call_to should be a phone number or SIP user, not a full SIP URI" )
145
144
}
146
145
if strings .HasPrefix (req .Address , "sip:" ) || strings .HasPrefix (req .Address , "sips:" ) {
147
- return nil , errors . New ( "address must be a hostname without 'sip:' prefix" )
146
+ return nil , psrpc . NewErrorf ( psrpc . InvalidArgument , "address must be a hostname without 'sip:' prefix" )
148
147
}
149
148
if strings .Contains (req .Address , "transport=" ) {
150
- return nil , errors . New ( "address must not contain parameters; use transport field" )
149
+ return nil , psrpc . NewErrorf ( psrpc . InvalidArgument , "address must not contain parameters; use transport field" )
151
150
}
152
151
if strings .ContainsAny (req .Address , ";=" ) {
153
- return nil , errors . New ( "address must not contain parameters" )
152
+ return nil , psrpc . NewErrorf ( psrpc . InvalidArgument , "address must not contain parameters" )
154
153
}
155
154
log := c .log
156
155
if req .ProjectId != "" {
0 commit comments