|
Exception handling |
|
|
Exceptions are handled by try/catch/throw as known by C++ and JAVA:
foo()
{
try {
....
var exc = { 'error in foo:', 'the message' };
throw exc;
....
} // try
catch (const xx[]) {
for (var i = 0; i < sizeof xx; i++)
sysLog(xx[i]);
} // catch
} // foo
Unlike C++ there may only be one catch block following the try block. The reason is, that there is only one variable type in CSL and it makes no sense to define several catch blocks. throw must be followed by an identifier name or an expression as argument. The identifier may be any simple var/const, or array with any number of dimensions. catch expects an identifier followed by empty braces [ ] as parameter. No matter what number of dimensions the thrown value had, the caught value will be a one-dimensional array. |
||||||||
| Copyright © IBK Landquart | Last revision: 27.05.2002 | << Back Top Next >> |