I'm throwing error before insert when there is duplicate email and performing some action, but when error is thrown all the operation i performed is rolled back. how to prevent rollback.
The rollback depends on how the DML was initiated.
Insert, update, delete, etc is an all or none and rollback will occur
Using database methods you can specify the behavior using the allOrNone option
Will allow records without error to be inserted and those with an error will not.
You can inspect the results using the SaveResult object.