[Work in Progress] Refactor ErrorHandler into an object.

 - Probably something for ownCloud 7
 - Needs unit tests