Throw Statement

The Throw statement causes Siebel eScript to stop running code if an error occurs.

Format

throw exception

The following table describes arguments for the Throw statement.

Argument Description

exception

An object in an error class.

Usage

In the following example, the Throw statement stops the script after Siebel CRM displays an error message:

try
{
   do_something;
}
catch( e )
{
   TheApplication().Trace (e.toString()));
throw e;
}

If any error occurs while processing a statement in a try block, then Siebel eScript creates an exception. An outer catch block can handle this exception. For example, assume a section of code includes three levels of try catch blocks:

  1. The innermost catch block includes a throw statement. An exception occurs.

  2. The catch statement in the level two block catches this exception.

  3. The catch statement in the level two block throws this exception to the level one block.

  4. The catch block at level one handles this exception.

The following code illustrates this example:

try
   {
   do_something;
   try
      {
      do_something;
      }
         catch(e)
      {
      TheApplication().Trace(e.toString());
      throw e;
      }
    }
      catch(e)
   {
   TheApplication().RaiseErrorText("Error Occurred "+e.toString());
}

You can write code that uses the RaiseErrorText method or the RaiseError method instead of the Throw statement to avoid receiving an unhandled exception error in the text that the Get Buffer Data method returns. If the Siebel Run-Time Engine creates an error message, or if the Throw statement creates an error message, then Siebel CRM adds the following text to the error message:

Unhandled Exception

Siebel CRM does this to distinguish an error message that the RaiseErrorText method or that the RaiseError method creates from an error that the Siebel Run-Time Engine creates or that the Throw statement creates.

For more information, see Get Buffer Data Method and Try Statement.