💾 Archived View for vierkantor.com › xukut › manual › swail › condition.gmi captured on 2024-07-08 at 23:26:00. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-10)

-=-=-=-=-=-=-

XukutOS manual → Swail → Conditions

Swail indicates situations that require exceptional control flow through *raising a condition*. In particular, Swail's builtin errors use the condition system.

When a condition is raised, control passes to the (dynamically determined) currently installed handler. The handler inspects the condition, and can decide between a variety of actions, including to stop the current process, to return a value to the condition caller, or to restart execution at another place in the context.

You can install *restarts* to return control to another place when a condition occurs. For example, you can go back to the start of a long computation if there's an error in one subcomputation. The term *default restart* means the consequences of returning a value from the handler, rather than the handler invoking a restart. At the moment, there isn't really a finished restart interface, stay tuned for more details as they emerge.

variable (dyn swail:handler)

The currently installed condition handler. The value bound to `handler' is called on each condition that is raised.

The default handler kills the current process and pops up an error message with debug information.

function (swail:condition context)

Raise a condition with information `context'.

The current handler is called on `context'. If the handler returns a value, this will be the result of the call to `condition' (this is considered invoking the default restart). A call to `condition' is quite likely not to return, for example when the handler decides to invoke a restart or to stop the current process entirely.

function (swail:error context)

Raise an error with information `context'.

This is currently a synonym of `condition', which conveys the additional information that the condition is caused by a programming mistake, rather than a recoverable, anticipated situation.

Any questions? Contact me:

By email at vierkantor@vierkantor.com

Through mastodon @vierkantor@mastodon.vierkantor.com

XukutOS user's manual: Swail

XukutOS user's manual

XukutOS main page