Passed
Push — 2.x ( 6a1f51...1afad9 )
by Jordi
05:47
created

senaite.core.z3cform.error   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 11
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A ValueErrorViewSnippet.createMessage() 0 3 1
1
# -*- coding: utf-8 -*-
2
3
from bika.lims import senaiteMessageFactory as _
4
from z3c.form.error import ErrorViewSnippet
5
from zope.component import adapter
6
from senaite.core.interfaces import ISenaiteFormLayer
7
8
9
@adapter(ValueError, ISenaiteFormLayer, None, None, None, None)
10
class ValueErrorViewSnippet(ErrorViewSnippet):
11
    """An error view for ValueError.
12
    """
13
14
    defaultMessage = _("Validation failed.")
15
16
    def createMessage(self):
17
        message = self.error.message
18
        return message or self.defaultMessage
19