How to get the data which are not successfully inserted in database?

I am inserting multiple records of cdt type to database in writetodatabaseentity() function. I want to get those records which are not successfully added to database. How to achive this?

  Discussion posts and replies are publicly visible