check if obj is an object, and raise meaningful exception