This is a common challenge when you are writing things to the database - and that's not limited to MongoDB either, since you can hit a network error or some other "transient" error completing an insert into any backend system.
First thing would be to always catch and exception and do the "appropriate" thing with the document you were inserting. Now, what is that "thing" - well, it depends on a few things - how safe is it to retry, whether you have ability to surface the error back to the application (and whether it would be able to take correct action at this point), etc. You should always have unique constraints on the fields that should not be duplicated (that may make it safe to just try to insert again).
In any case, you should probably log a detailed error and write the object you were trying to persist either in the logs or in another location where you can take appropriate action - even if it's just to post-mortem what happened.
Btw, I always assume this is what happens when I get an error from some site or application that says "Success of your <whatever> could not be determined, please check the status <in some other screen> and retry if appropriate" (instead of "Error saving <xyz> please try again later").
Asya