Refactoring error reporting to make it more simple and consistent