# throw

#### Availability

Flash Player 7.

#### Usage

    throw expression

#### Description

Action; generates ("throws") an error that can be handled ("caught") by a `catch` code block. If an exception is not caught by a `catch` statement, the string representation of the thrown value is sent to the Output window.

#### Parameters

`expression` An ActionScript expression or object.

#### Example

In this example...

    function GetSquareRoot(Number:val) {
    	try {
      		// Calculate the square root of the val parameter
    		if (val < 0 || isNaN(val) || !isFinite(val)) {
        			throw new SquareRootException();
      		}
      		return Math.sqrt(val);
    	} catch (e) {
      		// Display error message
    		if(e instanceof SquareRootException) {
      			trace("Square root failed; number may be out of range.");
    		} else {
    			trace("An unknown error occurred")
    	}
    }
    function SquareRootException()
    {
    }

#### See also

Error object, `try..catch..finally`