IrtError: message property

Available since @irtio/client 5.0BrowsersNode

The message read-only property of the IrtError interface describes the error for developers. It’s inherited from Error.

Value

A string, such as call buy got no reply within 10000 ms or the room kicked this connection (spamming chat), with the router’s or the room’s reason in it where there is one.

Description

message is for logs and for developers. Its wording isn’t part of the API, so branch on name and code, never on message. To show a player why something failed, show reason, or a sentence of the game’s own for the name or code.

Errors and close codes lists the messages that connect(), calls and the room-wide requests reject with.

Examples

Logging a dropped connection

The game logs why its connection ended, and shows the player a sentence of its own.

// log-close.ts
import type { ReadyRoomClient } from "@irtio/client";

export function logClose(room: ReadyRoomClient) {
  room.addEventListener("close", ({ error }) => {
    if (!error) return;
    console.error(`Connection to ${room.id} ended: ${error.message}`);
    document.querySelector("#status")!.textContent = "You've been disconnected.";
  });
}

See also

Runtime availability

BrowsersNode
message5.05.0