anfra docs
anfra SDK

Errors

The error classes the SDK raises and how to handle them

The SDK reports four kinds of error. Every error has an entity, the name of the query or control it concerns.

ClassWhenWhat to do
ValidationErrorThrown synchronously while declaring: unknown dataset, unknown filter field, duplicate name, invalid control mapping or cross-filter, or disabled capability. Also thrown by an invalid pageSize or select fields. Anfra.lineage rejects with one for an empty or malformed target list.Fix the declaring line it names. It surfaces as an uncaught error in the console.
QueryErrorStored on query.error: anfra rejected the AQL, a mapped field or an operator, or the query failed.Read the message. It names the AQL problem or the bad entry, such as filters[0].field. Compare executedAql with what you meant, then fix the AQL or the mapping.
PermissionErrorStored on query.error: the reader can't see the data.Render "no access" rather than a failure.
TransportErrorA network or session problem.Show a retry.

A local anfra serve never raises PermissionError, because its reader sees everything. A host that serves other people may.

Checking the class

The classes aren't exposed as globals, so check err.name:

if (query.state === 'error') {
  if (query.error.name === 'PermissionError') showNoAccess()
  else if (query.error.name === 'TransportError') showRetry()
  else showMessage(query.error.message)
}

Errors from a plugin

A plugin call, such as Anfra.lineage(), rejects with one of the four classes above, and its message is written for you to read. Any other failure on the host's side arrives as QueryError: The call failed., without its original message, because that message could hold a URL, an id or a server's internals.

What execute() does with failures

app.execute() never rejects. It resolves { succeeded, failed }, so a failing query does not stop the others. Read each query's state and error to render the failure next to the view that caused it.

On this page