---
url: https://trigger.beyondthecloud.dev/before-insert/add-ons/continue-on-error.md
description: >-
  Let a before insert handler fail without failing the insert - its exceptions
  are logged and swallowed, and the save goes on.
---

# BeforeInsert.ContinueOnError

Log and swallow the handler's exceptions, so later handlers still run and the insert goes on.

**Signature**

```apex
public interface ContinueOnError {
}
```

`BeforeInsert.ContinueOnError` has no methods: implementing it is the whole opt-in.

**Example**

::: code-group

```apex [Skeleton]
public with sharing class ContactPopulator implements BeforeInsert.Populator, BeforeInsert.ContinueOnError {
    public Boolean populateOnBeforeInsertWhen(TriggerTypes.InsertRecord record) {
        return record.isBlank(Contact.LeadSource);
    }

    public void populateOnBeforeInsert(TriggerTypes.InsertRecord record) {
        record.put(Contact.LeadSource, 'Web');
    }
}
```

:::

## Rules {#rules}

* **The handler stops for the chunk.** Its remaining records and its Finalizer are skipped. Values it already set and errors it already attached stay.
* **On a Validator, the rest goes unchecked.** Records after the failing one are saved unless another handler rejects them.
* **Add a [Logger](/guide/error-handling#logger).** Without one, a swallowed exception leaves no trace.

::: warning
Some exceptions still fail the insert: DML in the handler, a Validator that attaches no error, `TriggerTypes.TriggerLibException`, `System.LimitException`, and exceptions in `bypassOnBeforeInsertWhen()`, `queryParentsOnBeforeInsert()` or the parent query after a Populator.
:::
