catch

Typekeyword
DictionaryLCS
LibraryLiveCode Script
Syntax
catch <errorParameter>
Summary

Used within a try control structure to handle errors.

Introduced1.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
errorParameter
Example
catch myError
RelatedControl Structure: if, switch, try, throw
Glossary: return, handle, handler, execute, error, statement, execution error, keyword, control structure, command
Function: result, value
Description

Use the catch keyword to handle errors returned by a handler with the throw control structure.

When one of the statements in a try control structure causes an execution error, the errorParameter is set to the error string, and the statements after the catch keyword are executed. If LiveCode generates the error (for example, an execution error from a built-in command), the errorParameter is a positive number. An error string can also be returned from a handler by the throw keyword.

The statements after the catch keyword are only executed if there is an error. These statements can refer to the value of the errorParameter. For example, the catch section might contain an if or switch control structure, which does different things depending on the value of the errorParameter.