Improved logging of error conditions