Add a small error check
This is an ugly kludge to work around a bug that was discovered while working on an application.