Tiny code refactoring
Improved code for getting error message