Skip to content

Errors

This content is for the 0.2.0-alpha.3 version. Switch to the latest version for up-to-date documentation.

SDK methods reject with a standard Error whose message identifies the case. HTTP failures throw an HttpError carrying the status. Channel operations throw typed errors you can branch on.

import { ChannelNotFoundError, ChannelExistsError } from "@muhkoo/connect";
try {
await client.space.joinChannel("project-x");
} catch (err) {
if (err instanceof ChannelNotFoundError) {
// No channel with that name — offer to create it.
await client.space.createChannel("project-x");
}
}
  • ChannelNotFoundErrorjoinChannel(name) when the name isn’t registered. (carries .channelName.)
  • ChannelExistsErrorcreateChannel(name) when the name is already taken — join it instead.
import { HttpError } from "@muhkoo/connect";
try {
await client.storage.get("todos", "t1");
} catch (err) {
if (err instanceof HttpError) {
console.log(err.status); // e.g. 401, 402, 404
console.log(err.body); // parsed JSON error body, if any
}
}
WhereMessage / status containsCause & fix
logincommitment mismatch / incorrect passwordWrong password, or a legacy/incompatible account.
loginUser not foundNo account with that username.
loginchallengeAuth challenge expired/replayed — retry.
storagenot signed inNo session — login() / restore() first.
storageidentityEncrypted op needs an unlocked identity — login() or unlock(password).
messagenot signed inMessaging needs a signed-in user.
messagetarget must be 'user:…'send() only takes user:<id> targets; use publish() for pub/sub.
any requestHttpError 401 — API key requiredApp key missing/invalid, or minted against a different deployment (keys are per-environment).
any requestHttpError 402Usage quota exceeded for the app’s tier.
// Restore on boot without throwing on a stale token:
const user = await client.auth.zk.restore().catch(() => null);
// Gate encrypted reads on an unlocked identity:
if (client.auth.zk.identity) {
const data = await client.storage.get("notes", id);
}