Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/deform/exception.py : 50%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""Deform exceptions."""
4class ValidationFailure(Exception):
5 """
6 The exception raised by :meth:`deform.widget.Widget.validate`
7 (most often called as ``form.validate(fields)``) when the supplied
8 field data does not pass the overall constraints of the schema
9 associated with the widget.
11 **Attributes**
13 ``field``
14 The field :meth:`deform.form.Field.validate` was
15 called on (usually a :class:`deform.form.Form` object).
17 ``cstruct``
18 The unvalidatable :term:`cstruct` that was returned from
19 :meth:`deform.widget.Widget.deserialize`.
21 ``error``
22 The original :class:`colander.Invalid` exception raised by
23 :meth:`deform.schema.SchemaNode.deserialize` which caused
24 this exception to need to be raised.
25 """
27 def __init__(self, field, cstruct, error):
28 Exception.__init__(self)
29 self.field = field
30 self.cstruct = cstruct
31 self.error = error
33 def render(self, **kw):
34 """
35 Used to reserialize the form in such a way that the user will
36 see error markers in the form HTML.
38 The ``**kw`` argument allows a caller to pass named arguments
39 that are passed on to the template.
40 """
41 return self.field.widget.serialize(self.field, self.cstruct, **kw)
44class TemplateError(Exception):
45 pass