def publish_form(callback):
try:
return callback()
except (PyXFormError, XLSFormError) as e:
return {
'type': 'alert-error',
'text': unicode(e)
}
except IntegrityError as e:
transaction.rollback()
return {
'type': 'alert-error',
'text': _(u'Form with this id or SMS-keyword already exists.'),
}
except ValidationError as e:
# on clone invalid URL
return {
'type': 'alert-error',
'text': _(u'Invalid URL format.'),
}
except AttributeError as e:
# form.publish returned None, not sure why...
return {
'type': 'alert-error',
'text': unicode(e)
}
except ProcessTimedOut as e:
# catch timeout errors
return {
'type': 'alert-error',
'text': _(u'Form validation timeout, please try again.'),
}
except Exception as e:
transaction.rollback()
# error in the XLS file; show an error to the user
return {
'type': 'alert-error',
'text': unicode(e)
}
评论列表
文章目录