Assert
ceramic.Assert (Class)
Assertion utility for runtime validation in debug builds.
This class provides compile-time macros for asserting conditions during development. All assertions are automatically removed from release builds for zero runtime overhead.
Usage Example
// Basic assertion
Assert.assert(value > 0);
// Assertion with custom message
Assert.assert(array.length > 0, "Array must not be empty");
// Complex condition
Assert.assert(x >= 0 && x <= 100, "Value out of range");
Build Configuration
- Assertions are active in debug builds by default
- Use
-D ceramic_assert
to enable assertions in release builds - Use
-D ceramic_assert_print_stack
to print stack traces on assertion failures
See: ceramic.Utils.printStackTrace
Static Members
Assert the expression evaluates to true
.
This check is only done in debug
builds and doesn't affect release
builds.
When an assertion fails, it logs an error and throws an exception with the stringified expression and optional reason.
Name | Type | Default | Description |
---|---|---|---|
expr |
Dynamic | The expression to evaluate. Must resolve to a boolean value. | |
reason |
String | (optional) | Optional custom error message to include when assertion fails. If not provided, defaults to "Assertion failure". * |
Returns |
---|
Dynamic |