Abstract error handling to its own class