Added error message logging functionality.