Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

♻️(backend) compare LiveKit errors to the SDK not-found code

davd-gzld3302c8644a3
diff --git a/src/backend/core/services/participants_management.py b/src/backend/core/services/participants_management.py
index 3b08f453..0d0fea03 100644
--- a/src/backend/core/services/participants_management.py
+++ b/src/backend/core/services/participants_management.py
@@ -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(
diff --git a/src/backend/core/services/room_management.py b/src/backend/core/services/room_management.py
index c757becc..c50debeb 100644
--- a/src/backend/core/services/room_management.py
+++ b/src/backend/core/services/room_management.py
@@ -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,