Skip to content
← All release notesImprovedanfra0.17.0

Data App errors say what happened and who can fix it

Every error a Data App gets has the API's `code` and `scope`, so an app can tell a refused query from a server that's down.

err.scope says who must act: user for the reader's input or rights, client for the app's own code, and server when the server or host failed. err.code says what happened, such as query_invalid, query_failed, forbidden or connection_failed. err.requestId names the request in anfra serve's log, where the full cause is.

if (query.state === 'error') {
  const { code, scope, message } = query.error
  if (code === 'forbidden') showNoAccess()
  else if (scope === 'server') showRetry(() => app.execute())
  else showProblem(message)
}

Breaking

QueryError, PermissionError and TransportError are gone. Branch on err.code and err.scope instead of err.name. ValidationError stays for declarations, with code declaration_invalid.

Full changelog (opens in a new tab)