fix possible null reference in error message