Implements hook_ENTITY_TYPE_insert().
function entity_test_entity_test_insert($entity) { if ($entity->name->value == 'fail_insert') { throw new Exception("Test exception rollback."); } }