aboutsummaryrefslogtreecommitdiff
path: root/examples/safediv.micro
blob: b13b62ceef6d04e9d203c8f7a9796bce14b7850e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//
// Example of error handling
//

def safeDiv(a number, b number) number {
    if b == 0 {
        // error!
        return !? 0;
    }

    return a / b;
}

var result number;

if ? (result = safeDiv(1, 0)) {
    println("error in safeDiv");
}