throwing error if connecting to mongodb fails

Fixes #1