Fix error handling for duplicate question ID

http://manage.dimagi.com/default.asp?127310

@mwhite 
Minor refactoring here