Fixed a notice caused by improper error handling.