Anvil | Smiths Smiths | Register Register | Login Login |
Search:
Show links Show tools Show tree | Previous document Next document | njet.org > Anvil > Documentation > Language reference > Statements > Compound statements > Catch

Catch

Catch statement may appear standalone or together with try statement. Catch declares expception handler, that gets executed if and only if an exception is thrown inside the handler's scope. If catch is standalone then the scope starts from start of enclosing statement and ends just before ``catch´´. Otherwise scope is declared by the try statement.

Thrown exception (anything can be thrown), is assigned into expression given inside parenthesis.

When throwable is followed by colon and a type pointing to identifier, it gets executed only if the given throwable is instance of pointed type.

When throwable is followed by colon and an arbitrary expression (which may, or may not include the throwable itself) it gets executed only if the given expression yields "true" value.

  catch := "catch" "(" assignable-exprthrowable ")" statement 
  catch := "catch" "(" assignable-exprthrowable ":" identifiertype ")" statement 
  catch := "catch" "(" assignable-exprthrowable ":" expressioncondition ")" statement 
See also  | Statements  | Compound statements  | Finally  | Try  | Grammar  | Assignable primaries
Contributes notes:
Add a note
What's new | Anvil