refactoring error throws to avoid mongo from droping nodejs process