Skip to main content
All SDK errors extend UnlinkError with a code discriminator. Four subclasses ship: ApiError, CapabilityError, ValidationError, and TimeoutError.
import { ApiError, TimeoutError } from "@unlink-xyz/sdk/browser";

// Same shape from /client or /admin.

try {
  const tx = await client.deposit({ token, amount });
  await tx.wait({ timeoutMs: 60_000 });
} catch (err) {
  if (err instanceof TimeoutError) {
    console.error("Confirmation timed out:", err.txId);
  } else if (err instanceof ApiError) {
    console.error("Engine rejected:", err.code, err.detail);
  } else {
    throw err;
  }
}
Use CapabilityError for missing local setup, such as a missing EVM provider or an account that cannot execute. Use ValidationError for invalid SDK inputs. The ApiError class also covers transport failures. If a connection drops mid-response, the SDK throws ApiError with code: "CONNECTION_LOST" instead of leaking a raw TypeError. It is distinct from an Engine rejection, transient, and safe to retry. The underlying error is attached as err.cause.