mirror of
https://github.com/suitenumerique/meet.git
synced 2026-10-21 03:55:24 +00:00
♻️(backend) compare LiveKit errors to the SDK not-found code
Use TwirpErrorCode.NOT_FOUND rather than the bare string, as the SIP service already does.
This commit is contained in:
@@ -13,6 +13,7 @@ from livekit.api import (
|
||||
MuteRoomTrackRequest,
|
||||
RoomParticipantIdentity,
|
||||
TwirpError,
|
||||
TwirpErrorCode,
|
||||
UpdateParticipantRequest,
|
||||
)
|
||||
from livekit.protocol.models import ParticipantInfo
|
||||
@@ -53,7 +54,7 @@ class ParticipantsManagement:
|
||||
)
|
||||
|
||||
except (TwirpError, TimeoutError) as e:
|
||||
if isinstance(e, TwirpError) and e.code == "not_found":
|
||||
if isinstance(e, TwirpError) and e.code == TwirpErrorCode.NOT_FOUND:
|
||||
logger.warning(
|
||||
"Participant %s not found in room %s, skipping muting",
|
||||
identity,
|
||||
@@ -96,7 +97,7 @@ class ParticipantsManagement:
|
||||
RoomParticipantIdentity(room=room_name, identity=identity)
|
||||
)
|
||||
except (TwirpError, TimeoutError) as e:
|
||||
if isinstance(e, TwirpError) and e.code == "not_found":
|
||||
if isinstance(e, TwirpError) and e.code == TwirpErrorCode.NOT_FOUND:
|
||||
logger.warning(
|
||||
"Participant %s not found in room %s, skipping removing",
|
||||
identity,
|
||||
@@ -141,7 +142,7 @@ class ParticipantsManagement:
|
||||
)
|
||||
|
||||
except (TwirpError, TimeoutError) as e:
|
||||
if isinstance(e, TwirpError) and e.code == "not_found":
|
||||
if isinstance(e, TwirpError) and e.code == TwirpErrorCode.NOT_FOUND:
|
||||
logger.warning(
|
||||
"Participant %s not found in room %s, skipping update",
|
||||
identity,
|
||||
@@ -204,7 +205,7 @@ class ParticipantsManagement:
|
||||
)
|
||||
)
|
||||
except (TwirpError, TimeoutError) as e:
|
||||
if isinstance(e, TwirpError) and e.code == "not_found":
|
||||
if isinstance(e, TwirpError) and e.code == TwirpErrorCode.NOT_FOUND:
|
||||
raise ParticipantNotFoundException("Participant does not exist") from e
|
||||
|
||||
logger.exception(
|
||||
|
||||
@@ -14,6 +14,7 @@ from livekit.api import (
|
||||
DeleteRoomRequest,
|
||||
ListRoomsRequest,
|
||||
TwirpError,
|
||||
TwirpErrorCode,
|
||||
UpdateRoomMetadataRequest,
|
||||
)
|
||||
|
||||
@@ -81,7 +82,7 @@ class RoomManagement:
|
||||
)
|
||||
|
||||
except (TwirpError, TimeoutError) as e:
|
||||
if isinstance(e, TwirpError) and e.code == "not_found":
|
||||
if isinstance(e, TwirpError) and e.code == TwirpErrorCode.NOT_FOUND:
|
||||
raise RoomNotFoundException("Room does not exist") from e
|
||||
|
||||
logger.exception(
|
||||
@@ -109,7 +110,7 @@ class RoomManagement:
|
||||
await lkapi.room.delete_room(DeleteRoomRequest(room=room_name))
|
||||
logger.info("Deleted LiveKit room %s", room_name)
|
||||
except (TwirpError, TimeoutError) as e:
|
||||
if isinstance(e, TwirpError) and e.code == "not_found":
|
||||
if isinstance(e, TwirpError) and e.code == TwirpErrorCode.NOT_FOUND:
|
||||
logger.warning(
|
||||
"Room %s not found in LiveKit, skipping deletion",
|
||||
room_name,
|
||||
|
||||
Reference in New Issue
Block a user