fix overly generic error handling

I promised: http://manage.dimagi.com/default.asp?60198