Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

throws

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Marks a function as able to throw along a recoverable channel.

Syntax: fn <name>(...) throws → <type> [⇥ <error-type>]

Category#

error

Examples#

radix/corpus/reference/modifier/iacit/iacit.fab (canonical · modifier)#

Marks a function as able to throw along a recoverable channel.

# =============================================================================
# throws — Marks a function as able to throw along a recoverable channel.
# =============================================================================
#
# What this teaches:
#   • the `throws` modifier on function declarations — marks a function as throwable
#   • the `⇥` error type annotation for specifying the error type contract
#
# Common mistakes:
#   • Forgetting to declare the ⇥ error type — throws requires an explicit ⇥ error type in the function signature.
#
# See also: throw, catch, ⇥, errors, readonly
# =============================================================================

# meta/iacit — throwable function modifier
#
# GRAMMAR:
#   funcModifier :← 'throws'
#
# EXPECTED OUTPUT:
#   throws surface declared
#
# BACKEND:
#   Prefer explicit ⇥ error types for callable contracts; see throw/functio-fallibilis.fab.

interface Canens {
    fn canta(string vox) → void
}

main {
    print "iacit modifier declared"
}

Expected output:

iacit modifier declared