Error handler

Possible fix for https://github.com/owncloud/mail/issues/7