logger_tools.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:FormShare 作者: qlands 项目源码 文件源码
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)
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号