throw

returns an error message to a control structure.

# Metadata

Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 1.0 Security:

# Syntax

throw errorString

# Params

- errorString : The string that is returned to the calling try control structure. The errorString becomes the parameter of the catch line in the try control structure.

# Examples

open file tFile for text read

if the result is not empty then throw "failed_to_open_file" end if

# Description

**Form:** The throw statement appears on a line by itself, anywhere inside a handler.

If LiveCode generates the error (for example, an execution error from a built-in command), it returns a positive number to the try control structure. To avoid confusion, therefore, a throw control structure should return a negative number, or a non-numeric string.

If a throw control structure is execute in a handler that was not call from within a try control structure, an errorDialog message is sent to the object, and the errorString is passed as a parameter.

>*Note:* The throw control structure is implemented internally as a > command and appears in the commandNames.

# Tags

# See

- **keyword:** string, catch - **message:** errorDialog - **function:** commandNames - **glossary:** return, call, handler, execute, statement, message, negative, control structure, parameter, command, object - **control structure:** return, try