A little bit more sophisticated error handling.