gdDocumentation0.8.0

API reference

Err

A failure value with a category, message, details, causes, and partial result. Err.NOT_FOUND and related names are shared values. join() retains independent failures, and find() searches every cause.

Properties

msg : String
kind : Err

A failure value with a category, message, details, causes, and partial result. Err.NOT_FOUND and related names are shared values. join() retains independent failures, and find() searches every cause.

info : Dictionary
cause : Err

A failure value with a category, message, details, causes, and partial result. Err.NOT_FOUND and related names are shared values. join() retains independent failures, and find() searches every cause.

causes : Array
partial : Variant

Constants

ERROR = Err
NOT_FOUND = Err
PERMISSION_DENIED = Err
ALREADY_EXISTS = Err
INVALID_DATA = Err
TIMED_OUT = Err
INTERRUPTED = Err
UNSUPPORTED = Err
UNAUTHENTICATED = Err
LIMITED = Err

Methods

not_found

not_found(msg: String = "") -> Err

Report a missing target with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

permission_denied

permission_denied(msg: String = "") -> Err

Report rejected access with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

already_exists

already_exists(msg: String = "") -> Err

Report a duplicate target with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

invalid_data

invalid_data(msg: String = "") -> Err

Report malformed input with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

timed_out

timed_out(msg: String = "") -> Err

Report an expired deadline with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

interrupted

interrupted(msg: String = "") -> Err

Report interrupted work with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

unsupported

unsupported(msg: String = "") -> Err

Report unavailable behavior with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

unauthenticated

unauthenticated(msg: String = "") -> Err

Report failed authentication with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

limited

limited(msg: String = "") -> Err

Report exhausted capacity with optional detail.

Parameters

NameTypeDefaultDescription
msgString""Message text associated with this operation.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

from

from(reason: Variant, kind: Err = null) -> Err

Convert a reason while retaining the selected shared category.

Parameters

NameTypeDefaultDescription
reasonVariantRequiredFailure reason to retain in the result.
kindErrnullError kind used for classification and matching.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

join

join(errors: Array) -> Err

Combine two independent native failures without building a script array.

Parameters

NameTypeDefaultDescription
errorsArrayRequiredIndependent Err values to retain; null entries are ignored.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

as_kind

as_kind(kind: Err) -> Err

Reclassify an error with a shared category value.

Parameters

NameTypeDefaultDescription
kindErrRequiredError kind used for classification and matching.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

note

note(msg: String, info: Dictionary = {  }) -> Err

Add context and optional info fields to a new error value while retaining this value as its cause. New fields override copied fields only on the new value.

Parameters

NameTypeDefaultDescription
msgStringRequiredMessage text associated with this operation.
infoDictionary{ }Additional structured information attached to the error.

Return value

Err

A new Err with the original error as its cause.

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

Examples

return Err.NOT_FOUND.note("fetch item", {"code": "E_0008"})

See also

with_partial

with_partial(value: Variant) -> Err

Attach completed work to a new error without changing the original.

Parameters

NameTypeDefaultDescription
valueVariantRequiredValue to store, serialize, validate or pass to the operation described above.

Return value

Err

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

find

find(target: Variant, where: Dictionary = {  }) -> Err

Search this error and its causes. An Err target matches a shared category or an exact value; a dictionary target matches info fields on one error value. Every supplied field and its value type must match.

Parameters

NameTypeDefaultDescription
targetVariantRequiredShared category, exact Err value, or a nonempty dictionary of info fields to match.
whereDictionary{ }Optional info fields matched on the same Err value as the target.

Return value

Err

The first matching Err value, or null when none matches. An empty search dictionary does not match.

Errors

Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.

Examples

var conflict := e.find({"source": "postgres", "code": "40001"})
var missing := e.find(Err.NOT_FOUND, {"code": "E_0008"})

See also

text

text() -> String

Return a one-line description including causes.

Parameters

No parameters.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

name_of

name_of(kind: Err) -> String

Spell the category represented by a shared error value.

Parameters

NameTypeDefaultDescription
kindErrRequiredError kind used for classification and matching.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

names

names() -> PackedStringArray

List the category attributes exposed by the error class.

Parameters

No parameters.

Return value

PackedStringArray

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.