Axle v0.14.1
Package

std/core/checks

std/checks — runtime assertions / preconditions / postconditions.

Each helper throws on violation rather than aborting, so user
code can catch and recover when appropriate. The caller's
message is forwarded into the exception, so e.message reads
it back in the catch handler.

Naming follows Objects.requireNonNull /
assert / Preconditions.checkArgument conventions:

• require* = precondition (throws IllegalArgumentException)
• check* = state invariant (throws IllegalStateException)
• ensure* = postcondition (throws IllegalStateException)

Free functions

TypeMethod and description
void
requireTrue(condition : bool, message : string) : void Require condition to hold; throw IllegalArgumentException(message)
otherwise.
void
requireFalse(condition : bool, message : string) : void Require condition to be false; throw IllegalArgumentException(message)
otherwise.
void
requirePositive(value : i64, message : string) : void Require value > 0; throw IllegalArgumentException(message) otherwise.
Zero is rejected (use requireNonNegative to allow it).
void
requireNonNegative(value : i64, message : string) : void Require value >= 0; throw IllegalArgumentException(message) otherwise.
void
requireInRange( value : i64, min : i64, max : i64, message : string ) : void Require min <= value <= max (both bounds inclusive); throw
IllegalArgumentException(message) otherwise.
void
checkState(condition : bool, message : string) : void State invariants (different exception type so catch handlers can
distinguish a bad input from a bad object state).
void
fail(message : string) : void Hard fail — never returns. Useful for "unreachable" branches the
type checker can't prove dead.
void
requireNonEmpty(s : string, message : string) : void Require s to be non-empty; throw IllegalArgumentException
(prefixed with the check name) otherwise.

Method detail

#requireTrue

requireTrue(condition : bool, message : string) : void ! IllegalArgumentException

Require condition to hold; throw IllegalArgumentException(message)
otherwise.

Parameters
condition precondition that must be true to pass
message text forwarded into the exception when it fails

#requireFalse

requireFalse(condition : bool, message : string) : void ! IllegalArgumentException

Require condition to be false; throw IllegalArgumentException(message)
otherwise.

Parameters
condition precondition that must be false to pass
message text forwarded into the exception when it fails

#requirePositive

requirePositive(value : i64, message : string) : void ! IllegalArgumentException

Require value > 0; throw IllegalArgumentException(message) otherwise.
Zero is rejected (use requireNonNegative to allow it).

Parameters
value number that must be strictly greater than 0
message text forwarded into the exception when it fails

#requireNonNegative

requireNonNegative(value : i64, message : string) : void ! IllegalArgumentException

Require value >= 0; throw IllegalArgumentException(message) otherwise.

Parameters
value number that must be zero or greater
message text forwarded into the exception when it fails

#requireInRange

requireInRange( value : i64, min : i64, max : i64, message : string ) : void ! IllegalArgumentException

Require min <= value <= max (both bounds inclusive); throw
IllegalArgumentException(message) otherwise.

Parameters
value number checked against the inclusive bounds
min inclusive lower bound
max inclusive upper bound
message text forwarded into the exception when it fails

#checkState

checkState(condition : bool, message : string) : void ! IllegalStateException

State invariants (different exception type so catch handlers can
distinguish a bad input from a bad object state).

Parameters
condition state invariant that must be true to pass
message text forwarded into the IllegalStateException

#fail

fail(message : string) : void ! IllegalStateException

Hard fail — never returns. Useful for "unreachable" branches the
type checker can't prove dead.

Parameters
message text forwarded into the thrown IllegalStateException

#requireNonEmpty

requireNonEmpty(s : string, message : string) : void ! IllegalArgumentException

Require s to be non-empty; throw IllegalArgumentException
(prefixed with the check name) otherwise.

Parameters
s string that must have a non-zero byte length
message detail appended after the "requireNonEmpty: " prefix