raise custom exception when export is in a bad state

used to fix http://manage.dimagi.com/default.asp?88777#606002