Exception Handling

OTScript provides simple exception support with no type system but only a message.

This page discusses:

See Also
Basics

Syntax

An exception can be raised like this:

RAISE(message);

Use

No exception is raised, when the message has no value such as VOID(String).

A simple exception handing is made like this:

TMP succeed := { codeThatFails(); TRUE } CATCH FALSE;

It is possible to handle specific exceptions based on error message pattern.

Example

TMP status := { codeThatAbortsOrFails(); 0 }
  CATCH "": 1 // Empty message considered as abortion
  CATCH "Warning*": 2
  CATCH "Failed*": 3
  CATCH 4;