---
url: >-
  /statelake/scripting-reference/functions-and-procedures/exception-functions/raiseexception.md
---

# RaiseException

**RaiseException** will raise the exception to the next level of **Try...Except** statement block.

If **Try...Except** blocks are nested, then it fires the code of the upper block.

However, if this is the top level block then it is raised to **Statelake** for the default error handling to occur.

**Declaration**: Procedure RaiseException(ExceptionType, ExceptionParam);

An example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  Int1, Int2, Int3 : integer;
begin
 //Try to divide an integer by zero - to raise an exception
 try
    Int1 := 10;
    Int2 := 0;
    Int3 := Int1 / Int2;
 //These lines will execute if no error
    LogInfo('Fabulous!');
    LogInfo('There was no problem encountered!');
 except
    LogInfo('Exception occurred: ' + ExceptionToString(ExceptionType, ExceptionParam));
    LogInfo('');
    Int3 := 100;
    LogInfo('The variable has been set to '+IntToStr(Int3));
    LogInfo('');
 //Now use RaiseException to let Statelake automatically handle the error reporting
 //The Action will terminate after the RaiseException
    RaiseException(ExceptionType, ExceptionParam);
 end;
 //The following lines will never be processed
  LogInfo('');
  LogInfo('The Action has completed.');

 end;
```

Use of **LogWarning** will allow the **Action** to continue processing, and if not further errors are encountered, will produce a **GREEN** successfully processed log.

Use of **LogError** will force the **Action** to terminate and produce a **PINK** log.

Use of **LogInfo** however, will allow the **Action** to continue to process, regardless of the encountered error.

But the **Action** will terminate with the **RaiseException**, and no further lines will be processed as shown below.
