Fix for #817...sort of.

Added error trapping.