# What happens if an unhandled exception occurs inside a trigger during a bulk DML operation (insert list vs Database.insert(list, false))?

**Topic:** Apex Trigger · **Difficulty:** Hard · **Asked at:** Salesforce, Cognizant, LTIMindtree · **Tags:** apex-trigger, trigger, dml, exception-handling

Read it on the site: https://www.forcechallenges.com/interview-questions/what-happens-if-an-unhandled-exception-occurs-inside-a-trigger-during-a-bulk-dml-operation-insert-list-vs

## Answer

- `insert list;` (all-or-none): if any record fails or an uncaught exception occurs, the whole DML rolls back and a `DmlException` is thrown.
- `Database.insert(list, false)`: partial success is allowed. Records failing validation or `addError()` are reported in `SaveResult`s, others commit.

Important: an **unhandled exception thrown inside trigger code** (like a NullPointerException) is not a per-record failure; it fails the whole chunk and rolls it back, even with `allOrNone=false`. Use `addError` for record-level failures and try/catch for expected exceptions.

---
Source: ForceChallenges · last updated 2026-10-21
