PARTICIPANT_ERROR_CODES

expérimentaldepuis 0.1.0@legba-core/realtime

PARTICIPANT_ERROR_CODES

Ce que ça fait

La table des codes d’erreur stables liés à la gestion des participants.

Signature

const PARTICIPANT_ERROR_CODES: {
  INVALID_PARTICIPANT_REQUEST: "LEGBA_INVALID_PARTICIPANT_REQUEST";
  PARTICIPANT_NOT_FOUND: "LEGBA_PARTICIPANT_NOT_FOUND";
  FORBIDDEN: "LEGBA_PARTICIPANT_FORBIDDEN";
}

Paramètres

N/A — c’est une constante.

Retour

N/A — c’est une constante.

Erreurs

N/A.

Exemple minimal

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

console.log(PARTICIPANT_ERROR_CODES.FORBIDDEN); // "LEGBA_PARTICIPANT_FORBIDDEN"

Exemple complet

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

function isForbidden(error: unknown): boolean {
  return error instanceof LegbaParticipantError && error.code === PARTICIPANT_ERROR_CODES.FORBIDDEN;
}

Pièges

  • PARTICIPANT_NOT_FOUND couvre à la fois « la salle n’existe pas » et « le participant n’existe pas dans cette salle » pour getParticipant et removeParticipant : le serveur LiveKit renvoie le même message dans les deux cas, notre code ne peut donc pas les distinguer de façon fiable.

Voir aussi