Laurel User Guide

6. Exceptions🔗

Mainstream languages use exceptions to signal that an operation cannot complete normally, and to transfer control from the point of failure to the code prepared to handle it. Laurel models this directly: a procedure declares what it may throw with throws, a throw statement raises a value, and try / catch / finally handles it. Modelling exceptions here means each frontend does not have to re-implement them.

Laurel imposes no root exception type, and does not require a thrown value to belong to any particular hierarchy — a procedure may declare throws int and throw 3. What Laurel provides instead is subtype-aware typing of the catch binding, so each frontend uses its own hierarchy directly: Java's Throwable, Python's BaseException, or JavaScript's convention of throwing an Error.

  1. 6.1. Declaring and throwing
  2. 6.2. Catch or declare
  3. 6.3. Handling: try, catch, finally
  4. 6.4. The type of a catch binding
  5. 6.5. Exceptional contracts
  6. 6.6. Exceptional frames
  7. 6.7. Not yet supported