better exception handling
Merge pull request #48 from dimagi/ex

better exception handling