Standard Library: Panic
Terminate the program upon an unexpected program state
In constrast with errors (which signal anticipated error states), panics are used to indicate an unexpected program state from which recovery is not possible. Raising a panic terminates the program.
Module Contents
Panic.raise(message)
Raise a panic with the given message string.
score = -10
if score < 0 then
Panic.raise("score should never be negative")
end
panic: score should never be negative
Panic.raise("score should never be negative")
^
At Panic:embedded:4:14
Panic.unimplemented()
Raise a panic indicating an unfinished implementation.
score = 101
if score > 100 then
Panic.unimplemented()
end
panic: not implemented
Panic.unimplemented()
^
At Panic:embedded:4:22
Panic.unreachable()
Raise a panic indicating an unexpected program state.
score = -10
if score >= 0 then
score /= 2
else
Panic.unreachable()
end
panic: encountered unreachable code
Panic.unreachable()
^
At Panic:embedded:6:20