Passed
Push — develop ( 62612e...798305 )
by
unknown
03:13
created

atramhasis.errors   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 86
rs 10
c 0
b 0
f 0
wmc 14

14 Methods

Rating   Name   Duplication   Size   Complexity  
A ConceptSchemeNotFoundException.__str__() 0 2 1
A LanguageNotFoundException.__str__() 0 2 1
A ValidationError.__str__() 0 2 1
A SkosRegistryNotFoundException.__str__() 0 2 1
A ConceptNotFoundException.__str__() 0 2 1
A ConceptNotFoundException.__init__() 0 2 1
A ConceptSchemeNotFoundException.__init__() 0 2 1
A LanguageNotFoundException.__init__() 0 2 1
A SkosRegistryNotFoundException.__init__() 0 2 1
A ValidationError.__init__() 0 3 1
A DbNotFoundException.__init__() 0 2 1
A DbNotFoundException.__str__() 0 2 1
A SQLAlchemyProviderNotFoundException.__str__() 0 2 1
A SQLAlchemyProviderNotFoundException.__init__() 0 2 1
1
"""
2
Module containing errors generated by Atramhasis.
3
"""
4
5
from pyramid.httpexceptions import HTTPNotFound
6
7
8
class SkosRegistryNotFoundException(Exception):
9
    """
10
    Atramhasis could not find a SKOS registry.
11
    """
12
    def __init__(self, value='No SKOS registry found, please check your application setup'):
13
        self.value = value
14
15
    def __str__(self):
16
        return repr(self.value)
17
18
19
class ConceptSchemeNotFoundException(HTTPNotFound):
20
    """
21
    A ConceptScheme could not be found.
22
    """
23
    def __init__(self, scheme_id):
24
        self.value = 'No conceptscheme found with the given id ' + scheme_id
25
26
    def __str__(self):
27
        return repr(self.value)
28
29
30
class LanguageNotFoundException(HTTPNotFound):
31
    """
32
    A Language could not be found.
33
    """
34
    def __init__(self, scheme_id):
35
        self.value = 'No language found with the given id ' + scheme_id
36
37
    def __str__(self):
38
        return repr(self.value)
39
40
41
class ConceptNotFoundException(HTTPNotFound):
42
    """
43
    A Concept or Collection could not be found.
44
    """
45
    def __init__(self, c_id):
46
        self.value = 'No concept found with the given id ' + c_id
47
48
    def __str__(self):
49
        return repr(self.value)
50
51
52
class ValidationError(Exception):
53
    """
54
    Some data that was validated is invalid.
55
    """
56
    def __init__(self, value, errors):
57
        self.value = value
58
        self.errors = errors
59
60
    def __str__(self):
61
        return repr(self.value)
62
63
64
class DbNotFoundException(Exception):
65
    """
66
    Atramhasis could not find a database.
67
    """
68
69
    def __init__(self, value='No database found, please check your application setup'):
70
        self.value = value
71
72
    def __str__(self):
73
        return repr(self.value)
74
75
76
class SQLAlchemyProviderNotFoundException(HTTPNotFound):
77
    """
78
    SQLAlchemyProvider could not be found in the database.
79
    """
80
81
    def __init__(self, p_id):
82
        self.value = 'No SQLAlchemyProvider found with the given id ' + p_id
83
84
    def __str__(self):
85
        return repr(self.value)
86