Errors

A call can fail because a definition is missing, a document is invalid, or the database refuses a change. The examples use the people data to show these results. Use the status and diagnostic fields to identify the failure.

Binding errors

LanguageFailure
CReturns a status. The owner that its operation names holds the diagnostic.
GoReturns *Error.
RustReturns Result<_, Error>.
ClojureThrows clojure.lang.ExceptionInfo with diagnostic data.
PythonRaises StardustError.
OdinReturns an Error beside its result.

The error record gives the fields in your language. Statuses gives the failure conditions of each operation.

error

This record describes a failure with its status and diagnostic. The binding copies the diagnostic before it releases the native owner.

FieldTypeUnitAbsent
codestringNone—
messagestringNone—
pathMaybe(string)Nonenil
fieldMaybe(string)Nonenil
entityMaybe(builtin.i64)Nonenil
offsetMaybe(builtin.i64)Bytesnil
statusStatusNone—

Statuses

Each status names a class of failure. The table lists codes from the binding. Native diagnostic codes can differ.

.Invalid_Argument

Codes: time_out_of_range, invalid_argument, out_of_range, non_finite_number, cycle, unsupported_type, too_large, native_failure, live_children, wrong_kind, not_integral, inexact_number, missing_field, unknown_field, duplicate_field, too_deep, length_mismatch, malformed_tag, ambiguous_field, ambiguous_variant, invalid_value, hook_failed.

WhenOperations
the entity ID is outside the user entity range, max_depth is negative or above 32, or max_entities is negativeread_entity
the text is malformed, the format is unknown or a number is outside i64 or finite f64parse
the format is unknown or the width is negativeserialize
the text is malformed, a format is unknown or the width is negativeconvert
the node breaks the preorder rules or has an invalid kind or numberadd
a node breaks the preorder rules or has an invalid kind or numberadd_many
the builder has no root or a container is still openseal
id is not a node of the documentread, child_iterator
start is past the last node or capacity is negativeread_many
id is not an object node of the documentmember
the node is not an integer numberi64
the node is not a number or its value overflows f64f64
the arguments include an undeclared macro parameterbuild_macro, expand_macro
the file is not a database, an option is invalid or selected plugins are incompatibleopen
the parameters or run options are invalidrun, run
the parameters or subscription options are invalidsubscribe
max_wait is negativenext, indexes_sync
the patch is not an entity-keyed object, or a link names an ID outside the user entity rangemerge_patch
the kind, action, revision or page limits are invalid, or the selected plan cannot run the current authored definitionplan
the kind or the pattern is invaliddefinitions
a bulk build is already in progress on the databasebulk_begin
no bulk build is in progressbulk_add, bulk_finish
a name is empty, the plugin has no call operation with the name, or the plugin refuses the requestplugin_call
a name is empty, the plugin has no stream operation with the name, or the plugin refuses the requestplugin_stream
the stream has finished or does not accept writeswrite
the stream does not support reads, or length is negativeread
the stream does not support seeks, whence is unknown, or the position is negative or past the i64 rangeseek
the stream has finished or has no finish stepfinish
the token is empty or longer than 4096 bytesactivate
entity is not a user entityobjects_get, objects_path
the parent or the name is invalid, or the parent is a fileobjects_lookup
the parent is invalid or is a fileobjects_children
the digest is not 64 hexadecimal digitsobjects_files, objects_manifest, objects_open
the array is empty or malformed, a name is invalid, or a parent is a fileobjects_create
the entity is a directory or invalid, the digest is malformed, or expected_revision is negativeobjects_update
the request is malformed, the destination is a file or inside the node, the kinds differ, or a replaced directory is not emptyobjects_move
the entity is invalid, the directory is not empty, or expected_revision is negativeobjects_remove
options is not an object, or an option is invalid, duplicated or unsupportedreactors_sync, backups_sync, sdk_sync

.Invalid_JSON

WhenOperations
JSON text is malformedparse, convert

.Compile_Failed

WhenOperations
the expression does not compilebuild
the expansion does not compilebuild_macro
the expanded expression does not compileexpression

.Evaluation_Failed

WhenOperations
the expression fails on the inputevaluate
the query fails or exceeds max_costrun
the page does not rendernext
a page does not renderpage_iterator, all_pages
a rerun of the query failed. Every later call reports this failurenext
the mutation failsrun
the plugin cannot read its stored stateplugin_call, plugin_stream
stored bytes do not match their digestread
stored tree metadata or the manifest of a named payload is corruptedobjects_get, objects_lookup, objects_children, objects_path
the stored manifest is corruptedobjects_manifest, objects_open

.Out_Of_Memory

Codes: out_of_memory.

.Not_Found

Codes: not_found.

WhenOperations
the object has no member with the keymember
the macro refers to an unknown macrobuild_macro, expand_macro
the parent directory is missing, or the file is missing and create is falseopen
no definition is stored at the pathquery, mutation, definition
no expression is stored at the pathexpression
the stored query definition was deletedrun
the definition or exact historical plan revision does not existplan
the plugin reports that the request names nothing it holdsplugin_call, plugin_stream
no object node has the entityobjects_get
the parent has no child with the name, or the parent does not existobjects_lookup
the parent does not existobjects_children
the node or one of its ancestors does not existobjects_path
no payload with the digest is publishedobjects_manifest, objects_open
a parent does not exist or a digest is not publishedobjects_create
the file does not exist or the digest is not publishedobjects_update
the node or the destination does not existobjects_move
the node does not existobjects_remove

.Locked

WhenOperations
another process holds the lock after lock_timeoutopen

.Conflict

WhenOperations
an enabled plugin finds the database inconsistent with its copies: backups refuse diverging copies with code backup_history_divergent, naming themopen
concurrent writes prevent the commitrun
an entity revision check fails or a concurrent writer prevents the commit; a revision mismatch reports the entity and expected and actual revisionsmerge_patch
the authored definition or accepted plan changed before the explicit control committedplan
another write committed to the database during the buildbulk_finish
the plugin's write lost to a concurrent change, or the database holds writesplugin_call
the database holds writesplugin_stream, finish, objects_upload
the database holds writes while the plugin stores the byteswrite
a name is already taken in its parent or appears twice, or the database holds writesobjects_create
expected_revision is stale, or the database holds writesobjects_update, objects_remove
the name is occupied without replace, expected_revision is stale, or the database holds writesobjects_move

.Invalid_Definition

WhenOperations
the macro is invalid or expands recursivelybuild_macro, expand_macro
the definition is invalidquery, mutation
a macro it calls is invalid or expands recursivelyexpression
the loaded query definition is invalidrun
the query or its callable definitions are invalidsubscribe
the mutation selection or definition is invalidrun
the patched definition is invalidpatch_definition

.Schema_Violation

WhenOperations
the write breaks a schemarun

.Invalid_Commit_Time

WhenOperations
the #_tx commit time is not later than the last commitmerge_patch

.Closed

Codes: closed.

.Rejected

WhenOperations
a mutation target or write guard refuses the writerun
the database refuses the patch; the code and diagnostic path name the reason and keymerge_patch
the database refuses the patch; the build has failed and later adds report the same statusbulk_add
the database refuses a patch; an initial build publishes nothing and fallback keeps earlier commitsbulk_finish

.Unsupported

Codes: abi_version, core_digest.

WhenOperations
found differs from the ABI version of the bindingcheck_version

.Cancelled

Codes: cancelled.

WhenOperations
the subscription is cancelled or closednext

.Timeout

WhenOperations
max_wait passed firstindexes_sync
the plugin's wait passed its limitplugin_call
maxWait passed before the work finishedreactors_sync, sdk_sync
maxWait passed before every target confirmedbackups_sync

.Unavailable

WhenOperations
an enabled plugin cannot reach what the open needs: backups refuse with backup_targets_unreachable, backup_target_unreadable or backup_objects_requiredopen
the patch sets stardust/history and no enabled plugin purges historyrun, merge_patch
the plugin is unknown or the database does not enable itplugin_call, plugin_stream
the database does not enable the objects pluginobjects_get, objects_lookup, objects_children, objects_path, objects_files, objects_manifest, objects_create, objects_update, objects_move, objects_remove, objects_upload, objects_open
the database does not enable the reactors pluginreactors_status, reactors_sync
the database does not enable the backups pluginbackups_status, backups_sync
the database does not enable the sdk pluginsdk_status, sdk_sync

.Failed

WhenOperations
the plugin's work failedplugin_call
the plugin's work failed; status describes the failurereactors_sync, backups_sync, sdk_sync

.Unlicensed

Codes: unlicensed.

WhenOperations
the token is refused; the error names the reasonactivate

Refusal examples

The generator captured each result from the native library.

Describe the backup runtime

odin105 B
failed, result := stardust.backups_status(db)
defer stardust.close(&failed)
defer stardust.close(&result)
Result / 165 B
{
  "code": "unavailable",
  "message": "the plugin is not enabled",
  "path": null,
  "field": null,
  "entity": null,
  "offset": null,
  "status": "unavailable"
}

Wait until every target stored the history

odin188 B
sync_options := stardust.parse(`{maxWait {#dur PT5S}}`, .DUST) or_return
defer stardust.close(&sync_options)
result := stardust.backups_sync(db, sync_options)
defer stardust.close(&result)
Result / 165 B
{
  "code": "unavailable",
  "message": "the plugin is not enabled",
  "path": null,
  "field": null,
  "entity": null,
  "offset": null,
  "status": "unavailable"
}

convert

duplicate_text holds this document:

json14 B
"{:a 1 :a 2}"
odin271 B
source := stardust.parse(duplicate_text, .JSON) or_return
defer stardust.close(&source)

view := stardust.read(source, stardust.root(source) or_return) or_return
failed, result := stardust.parse(view.text, .EDN)
defer stardust.close(&failed)
defer stardust.close(&result)
Result / 181 B
{
  "code": "invalid_edn",
  "message": "invalid EDN (Duplicate_Key) at offset 6",
  "path": null,
  "field": null,
  "entity": null,
  "offset": 6,
  "status": "invalid_argument"
}

Refuse a metadata-only transaction

patch_text holds this document:

json38 B
{
  "#_tx": {
    "author": "x"
  }
}
odin192 B
patch := stardust.parse(patch_text, .JSON) or_return
defer stardust.close(&patch)

commit, result := stardust.merge_patch(db, patch)
defer stardust.close(&commit)
defer stardust.close(&result)
Result / 199 B
{
  "code": "transaction_only",
  "message": "a patch of only #_tx is refused: #_tx annotates a write",
  "path": "#_tx",
  "field": null,
  "entity": null,
  "offset": null,
  "status": "rejected"
}

Refuse a repeated commit time

future_text holds this document:

json120 B
{
  "#_d": {
    "x": 1
  },
  "#_tx": {
    "stardust/committedAt": {
      "#utc": "2200-01-01T00:00:00Z"
    }
  }
}

older_text holds this document:

json120 B
{
  "#_e": {
    "x": 2
  },
  "#_tx": {
    "stardust/committedAt": {
      "#utc": "2200-01-01T00:00:00Z"
    }
  }
}
odin368 B
future := stardust.parse(future_text, .JSON) or_return
defer stardust.close(&future)

committed := stardust.merge_patch(db, future) or_return
defer stardust.close(&committed)

patch := stardust.parse(older_text, .JSON) or_return
defer stardust.close(&patch)

commit, result := stardust.merge_patch(db, patch)
defer stardust.close(&commit)
defer stardust.close(&result)
Result / 227 B
{
  "code": "invalid_commit_time",
  "message": "stardust/committedAt must be strictly newer than the latest commit time",
  "path": null,
  "field": null,
  "entity": null,
  "offset": null,
  "status": "invalid_commit_time"
}

Refuse an invalid query definition

query_text holds this document:

json29 B
{
  "find": [
    "?x"
  ]
}
odin199 B
definition := stardust.parse(query_text, .JSON) or_return
defer stardust.close(&definition)

query, result := stardust.query(db, definition)
defer stardust.close(&query)
defer stardust.close(&result)
Result / 168 B
{
  "code": "unbound_variable",
  "message": "Unbound_Variable",
  "path": null,
  "field": null,
  "entity": null,
  "offset": null,
  "status": "invalid_definition"
}

Report a missing stored query

odin112 B
query, result := stardust.query(db, "people/missing")
defer stardust.close(&query)
defer stardust.close(&result)
Result / 174 B
{
  "code": "not_found",
  "message": "no definition at this path",
  "path": "people/missing",
  "field": null,
  "entity": null,
  "offset": null,
  "status": "not_found"
}

Report a malformed byte at offset zero

malformed holds these bytes:

text1 B
]
odin110 B
failed, result := stardust.parse(malformed, .DUST)
defer stardust.close(&failed)
defer stardust.close(&result)
Result / 169 B
{
  "code": "invalid_dust",
  "message": "Invalid_Syntax at offset 0",
  "path": null,
  "field": null,
  "entity": null,
  "offset": 0,
  "status": "invalid_argument"
}

Report malformed DUST

malformed holds these bytes:

text1 B
[
odin110 B
failed, result := stardust.parse(malformed, .DUST)
defer stardust.close(&failed)
defer stardust.close(&result)
Result / 169 B
{
  "code": "invalid_dust",
  "message": "Unexpected_End at offset 2",
  "path": null,
  "field": null,
  "entity": null,
  "offset": 2,
  "status": "invalid_argument"
}