Refs #8776. Improve error handling a bit.