ClosedBit error docs

CB_ERR_UNDERFLOW

Numeric underflow. A checked unsigned operation produced a value below zero.

Why it happens

A checked unsigned operation produced a value below zero.

How to fix it

Compare before subtracting, clamp to zero, or use a signed type when negative values are intended.

Copy-paste fix pattern
library CB-Math

fn main() {
    u256 health = 20
    u256 damage = 50
    u256 safeHealth = CB-Math.max(health - CB-Math.min(health, damage), zero)
    save safeHealth
}
Runtime and Studio now show this kind of page from the error dialog: plain message first, stable code second, original details third.