---
url: >-
  /statelake/scripting-reference/functions-and-procedures/logging-functions/logerrorandcontinue.md
---

# LogErrorAndContinue

**LogErrorAndContinue** creates an entry in the action **Log** of type **User Error**.

With **LogError**, further code in this script will execute but the mapping will stop after this event, and a **LogError** will result in a **PINK log** with a failed status.

But with **LogErrorAndContinue**, the rest of the map will continue to execute. But at the end of the map, the action will stop with a failed status and a **PINK log**.

This provides the opportunity to capture all the errors that are going to occur during the execution of the map, and report them to the user in one go.

Otherwise with **LogError** the user may fix the first error and then re-run the process only to get another error later in the map.

::: warning
Be careful when using this function - it is possible that there is a later dependence on the first error and therefore a cascading error can occur. For instance if you are trying to retrieve a value and an error occurs, you might have another error later because the value is missing. **LogError** would have stopped after the first error but this function will continue and raise another error because of the missing value. This can confuse a user because in reality all they need to do is fix the first error and the second would not have happened.

So when using this function always make sure that there is not going to be cascading errors.
:::

By using this function you are indicating to the user that an error has occurred that cannot be recovered from automatically, and therefore the user needs to step in.

The message **aMesg** that is logged should be precise and detailed enough to provide sufficient information for the user to fix the problem, and re-run the action.

**Declaration**: procedure LogErrorAndContinue(aMesg : string);

An example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
begin
 if MyData.EOF then
    LogErrorAndContinue('You are at the end of records in MyData recordset');
end;
```

A more complex example follows.

```pascal
procedure ScriptEvent (var Value : variant);
var
  Int1, Int2, Int3 : integer;
  Int4, Int5 : integer;
begin
  LogInfo('');
 //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('This is the 1st statement to execute if there is no error.');
    LogInfo('This is the next statement to execute if there is no error.');
 except
    LogInfo('Error occurred.');
    LogErrorAndContinue('Exception: '+ExceptionToString(ExceptionType, ExceptionParam));
 end;

  LogInfo('The script keeps processing.');
  LogInfo('Because of the LogErrorAndContinue . . . no immediate failed action ');
  Int4 := 12;
  Int5 := 10;
  LogInfo('Calculated value is - '+IntToStr(Int4*Int5));
  LogInfo('Final line. . . ');

  LogInfo('');
end;
```

The above code generates the following **Log**. Note the use of **LogInfo** supply further messages to the user.

Please also refer to [LogError](/statelake/scripting-reference/functions-and-procedures/logging-functions/logerror) and the other **Logging** functions.
