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 Field Type Description .causeerror The error that led to this one, or null. .columnnumber The column the error came from. .filestring The script the error came from. .linenumber The line the error came from. .messagestring What went wrong. .statusnumber The HTTP status its error type carries, such as 404, or null. .typestring The 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
.kscript XML Copy
<error name="PersonNotFound" extends="NotFound" />
<try>
<throw value="PersonNotFound()" />
<catch as="err"><echo>{ $err->chain() }</echo></catch>
</try>.kscript XML Copy
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
.kscript XML Copy
<try>
<throw value="FileNotFound('No settings.json')" />
<catch as="err"><echo>{ $err->is(IO) }</echo></catch>
</try>.kscript XML Copy
try {
throw FileNotFound('No settings.json')
} catch err {
echo $err->is(IO)
}Methods from any