Added more precise error message handling.