Check for valid cursor at start of om/build.

This results in a stack trace which contains the offending call to om/build.