ResourceKit
API Reference

Errors

Every failure carries a stable code - here's what each one means.

All ResourceKit errors extend ResourceKitError and carry a stable code. Codes survive the network - an error raised on the server arrives at the client with its meaning intact.

import { ResourceKitError } from "resourcekit";

try {
  await assign.run(id, { userId });
} catch (error) {
  if (error instanceof ResourceKitError && error.code === "conflict") {
    // someone else edited this record
  }
}

Codes

CodeMeansTypical reaction
conflictThe write lost to a concurrent edit; it was rolled back and the winner fetchedTell the user - see Conflicts
access_deniedOutside the caller's access scope, or the resource has no ruleUsually a bug in UI state - the user shouldn't have been able to try
invalid_inputA record, patch, or input failed schema validationFix the form / the caller
not_foundA write addressed a record that doesn't existRefresh the view
result_limitA read matched more rows than the server's maxRowsNarrow the filter or window with .take(n)
rejectedThe server refused for a business reason (e.g. a server-only action threw)Show the message
unsupportedThe resource doesn't support this operation (e.g. where on a Stripe-backed resource)A bug - the typed API normally prevents it; only a stale or hand-built plan reaches here
transportThe network failed - retryable; writes queue instead of failingUsually nothing: offline handling has it
unknown_resource / no_backboneConfiguration mismatch between client and serverFix the setup - these shouldn't reach production
internalAnything unexpected server-sideLog it

Error classes

Common cases also have classes for instanceof checks:

import {
  ConflictError,
  AccessDeniedError,
  InvalidInputError,
  NotFoundError,
  MutationRejectedError,
  TransportError,
  UnsupportedOperationError,
} from "resourcekit";

Checking error.code is equally valid and survives serialization boundaries - prefer it in generic handlers.

Where errors surface

  • Reads: useSynced exposes refresh failures as error (network loss isn't an error - it's status: "offline").
  • Writes: the run() / mutate() promise rejects, and useAction mirrors it as error / isConflict. The optimistic change is already rolled back by then.
  • Server-only code: throw ResourceKitErrors (or anything) from action and query implementations - the message travels to the client, the code defaults to rejected/internal.

On this page