throw

Summary

Throws a user-defined exception.

Syntax

throw object;

Parameters

object
The exception object to throw.

Description

The throw statement will throw an exception you specify.

Examples

Basic Usage
1
2
3
4
5
6
7
8
9
10
import System;
 
int add(int a, int b) {
    if (a >= 0 && b >= 0) {
        return a + b;
    }
    else {
        throw new Exceptions.OutOfRangeException("'add' expects two positive integers.");
    }
}

See Also

Share

HTML | BBCode | Direct Link