KScript docs
EN

error fields and methods

A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).

Fields

FieldTypeDescription
.causeerrorThe error that led to this one, or null.
.columnnumberThe column the error came from.
.filestringThe script the error came from.
.linenumberThe line the error came from.
.messagestringWhat went wrong.
.statusnumberThe HTTP status its error type carries, such as 404, or null.
.typestringThe error type, such as FileNotFound.

From KScript.Core

#error->chain() → list

The error's type and the types it extends, nearest first: ['NotFound', 'Validation', 'Error'].
Example
<error name="PersonNotFound" extends="NotFound" />
<try>
  <throw value="PersonNotFound()" />
  <catch as="err"><echo>{ $err->chain() }</echo></catch>
</try>
error PersonNotFound extends NotFound
try {
  throw PersonNotFound()
} catch err {
  echo $err->chain()
}

#error->is(type) → bool

True when the error is this type or one that extends it: $err->is(NotFound), $err->is(IO).
Example
<try>
  <throw value="FileNotFound('No settings.json')" />
  <catch as="err"><echo>{ $err->is(IO) }</echo></catch>
</try>
try {
  throw FileNotFound('No settings.json')
} catch err {
  echo $err->is(IO)
}

Methods from any