Fixed mongoose integration and added error handling for mongoose
exceptions.