...
- Java Exceptions - thrown from the java code running behind SIL
- SIL objects thrown using throw (explained below)
Throwing SIL Objects
The general syntax for throwing an exception from SIL is:
...
Code Block |
---|
throw errorCode; throw 2; throw array[0].fieldName; throw ("Fiend value invalid: " + structure.field); throw "Generic error!"; |
Try-catch block
Code Block | ||
---|---|---|
| ||
try { <instructions> } catch <type> <varName> { // handle <varName> } catch { // handle other error } |
...
If a matching catch clause was found, the instructions within the catch block are executed and the program will continue. If no matching catch clause is found, the exception is thrown inside the outer code block. This makes it possible to nest try-catch blocks within one another and throw exceptions from the inner block to be caught by the topmost one.
Examples
Code Block | ||
---|---|---|
| ||
try { number errorCode = 2; throw errorCode; } catch string s { // will not match } catch number err { // will match because a number was thrown //err = 2 } |
...