Example #1
0
 def _inner(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except (
         ColumnNotFoundException,
         ProgrammingError,
         InvalidQueryColumn,
     ) as e:
         error = translate_programming_error(e)
         if isinstance(error, TableNotFoundWarning):
             raise error
         raise UserReportsError(str(e))
Example #2
0
 def _inner(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except (
         ColumnNotFoundException,
         ProgrammingError,
         InvalidQueryColumn,
     ) as e:
         error = translate_programming_error(e)
         if isinstance(error, TableNotFoundWarning):
             raise error
         if not settings.UNIT_TESTING:
             _soft_assert(False, six.text_type(e))
         raise UserReportsError(six.text_type(e))
Example #3
0
    def handle_exception(self, doc, exception):
        ex = translate_programming_error(exception)
        if ex is not None:
            raise ex

        orig_exception = getattr(exception, 'orig', None)
        if orig_exception and isinstance(orig_exception, psycopg2.IntegrityError):
            if orig_exception.pgcode == psycopg2.errorcodes.NOT_NULL_VIOLATION:
                from corehq.apps.userreports.models import InvalidUCRData
                InvalidUCRData.objects.create(
                    doc_id=doc['_id'],
                    doc_type=doc['doc_type'],
                    domain=doc['domain'],
                    indicator_config_id=self.config._id,
                    validation_name='not_null_violation',
                    validation_text='A column in this doc violates an is_nullable constraint'
                )
                return

        super(ErrorRaisingIndicatorSqlAdapter, self).handle_exception(doc, exception)
Example #4
0
    def handle_exception(self, doc, exception):
        ex = translate_programming_error(exception)
        if ex is not None:
            raise ex

        orig_exception = getattr(exception, 'orig')
        if orig_exception and isinstance(orig_exception, psycopg2.IntegrityError):
            if orig_exception.pgcode == psycopg2.errorcodes.NOT_NULL_VIOLATION:
                from corehq.apps.userreports.models import InvalidUCRData
                InvalidUCRData.objects.create(
                    doc_id=doc['_id'],
                    doc_type=doc['doc_type'],
                    domain=doc['domain'],
                    indicator_config_id=self.config._id,
                    validation_name='not_null_violation',
                    validation_text='A column in this doc violates an is_nullable constraint'
                )
                return

        super(ErrorRaisingIndicatorSqlAdapter, self).handle_exception(doc, exception)
Example #5
0
 def handle_exception(self, doc, exception):
     ex = translate_programming_error(exception)
     if ex:
         raise ex
     super(ErrorRaisingIndicatorSqlAdapter, self).handle_exception(doc, exception)
Example #6
0
 def handle_exception(self, doc, exception):
     ex = translate_programming_error(exception)
     if ex:
         raise ex
     super(ErrorRaisingIndicatorSqlAdapter, self).handle_exception(doc, exception)