← index

Error

inherits Object · defined at core/00-bootstrap.qn:111

The root of every throwable error: a human-readable message plus an optional payload. Subclass it for your own error types (Error <- MyError <- {}) and catch by type with block.catch:{ |e:MyError| ... }.

Class methods

throw:

Convenience constructor that builds an instance and immediately throws, e.g. TypeError.throw:'expected an Integer'. Inherited by subclasses.

core/00-bootstrap.qn:115

throw: payload:

Like throw:, also attaching a payload value the handler can read back.

{ Error.throw:'no key' payload:#missing }
    .catch:{ |e:Error| e.payload }    "* -> missing

core/00-bootstrap.qn:122

Instance methods

message

The human-readable description this error was thrown with.

core/00-bootstrap.qn:126

payload

The value attached at the throw site (throw:payload:), or nil.

core/00-bootstrap.qn:128

s

Renders as class name and message.

{ TypeError.throw:'nope' }.catch:{ |e:TypeError| e.s }    "* -> TypeError: nope

core/00-bootstrap.qn:135