Exception handling

C Scripting Language
Reference Manual
Version 4.4.0

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using the CSL executive
Language
   Comments
   Numbers
   Literals
   Var and const
   Operators
   Statements and blocks
   Program flow
   Trace facility
   Exception handling
      Between CSL and C
      Between CSL and C++
   Functions
   Predefined identifiers
Directives
System library
String library
Math library
Regular expression lib.
File library
Database library
Async Communication
Registry/Profile handling
Windows control
C API
C++ Class Interface
CSL links
  

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 >>