Example of the Throwing Exception Policy
The following is an example of the throwing exception policy. In this example, an overflow occurs in an attempt to calculate Int64.Max + 1, and OverflowException is thrown.
import std.overflow.*
import std.math.*
main() {
let a: Int64 = Int64.Max
println(a.throwingAdd(1))
}
The running result is as follows:
An exception has occurred:
OverflowException: add