Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Java Exceptions - thrown from the java code running behind SIL
  2. 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
titleSyntax
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
titleType matching
try {
	number errorCode = 2;
	throw errorCode;
} catch string s {
	// will not match
} catch number err {
	// will match because a number was thrown
    //err = 2
}

...