LegbaParticipantError

expérimentaldepuis 0.1.0@legba-core/realtime

LegbaParticipantError

Ce que ça fait

Erreur levée par les méthodes de ParticipantService.

Signature

class LegbaParticipantError extends LegbaError {
  constructor(code: ParticipantErrorCode, message: string);
}

Paramètres

NomTypeRequisDéfautDescription
codeParticipantErrorCodeouiUn des codes de PARTICIPANT_ERROR_CODES
messagestringouiMessage actionnable

Retour

Une instance de LegbaParticipantError, avec name === "LegbaParticipantError".

Erreurs

N/A — c’est la classe d’erreur elle-même.

Exemple minimal

import { LegbaParticipantError, PARTICIPANT_ERROR_CODES } from "@legba-core/realtime";

try {
  await participants.removeParticipant({ roomName, identity, requestedByRole: "viewer" });
} catch (error) {
  if (error instanceof LegbaParticipantError && error.code === PARTICIPANT_ERROR_CODES.FORBIDDEN) {
    console.log("seul un hôte peut faire ça");
  }
}

Exemple complet

Voir createParticipantService.

Pièges

  • Le code FORBIDDEN signale un rôle appelant insuffisant (requestedByRole), pas un refus du serveur LiveKit lui-même — cette vérification est entièrement faite par @legba-core/realtime, avant tout appel réseau.

Voir aussi