cubicweb #17047951 Integrity errors do not show up nicely in the web interface [validation pending]

To reproduce, use an IntervalBoundConstraint(minvalue=0) on a float attribute, submit a negative value. You get a traceback like:

IntegrityError: ERREUR:  la nouvelle ligne viole la contrainte de vérification « cw_centrifugalcoolproductionunit » de la relation « cstr16b09c7a7d63aa8fc5643301faea6190 »
DETAIL:  La ligne en échec contient (83139, name1, 2017-01-19 11:46:32.743223+00, 2017-01-19 11:46:32.743223+00, http://syrah:8080/83139, 0.9, 9000, 1, 1, 0.1, 0.1, -271.15, -266.85, -263.55, -240.55, 0.80764, 0.021665, -0.000964, 0.086311, -0.0047495, 0, 0.72356, 0.012242, -1.49e-08, -0.021582, 0.0019701, 0, 0, 0, 0, 0, 0, null)

2017-01-19 12:46:32 - (cubicweb.pyramid.bwcompat) ERROR: 'ascii' codec can't decode byte 0xc3 in position 51: ordinal not in range(128)
Traceback (most recent call last):
  File "/home/florent/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/tweens.py", line 22, in excview_tween
    response = handler(request)
  File "/home/florent/cw/cubicweb/cubicweb/pyramid/bwcompat.py", line 180, in __call__
    response = self.cwhandler(request)
  File "/home/florent/cw/cubicweb/cubicweb/pyramid/bwcompat.py", line 78, in __call__
    content = controller.publish(rset=rset)
  File "/home/florent/cw/cubicweb/cubicweb/web/views/basecontrollers.py", line 253, in publish
    status, args, entity = _validate_form(self._cw, self._cw.vreg)
  File "/home/florent/cw/cubicweb/cubicweb/web/views/basecontrollers.py", line 232, in _validate_form
    return (False, text_type(ex), ctrl._edited_entity)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 51: ordinal not in range(128)

Since more and more constraints were moved to the db backend, we have to improve backend exception handling dramatically. psycopg2 exposes enough details to figure out which yams constraint raised the error, so that we can improve user experience up to the point we were before moving constraint enforcement to the backend.

priorityimportant
typebug
done in3.24.4
load left0.000
closed by#2deb9f6cbb7b [source,native] Generalize the IntegrityError constraint parsing regex
patch[source,native] Generalize the IntegrityError constraint parsing regex [applied]