-
Notifications
You must be signed in to change notification settings - Fork 9
/
errors.py
99 lines (62 loc) · 2.58 KB
/
errors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
"""
.. module:: MyCapytain.errors
:synopsis: MyCapytain errors
.. moduleauthor:: Thibault Clérice <leponteineptique@gmail.com>
"""
class MyCapytainException(BaseException):
""" Namespacing errors
"""
class JsonLdCollectionMissing(MyCapytainException):
""" Error thrown when a JSON LD contains no principle collection
Raised when a json supposed to contain collection is parsed
but nothing is found
"""
class DuplicateReference(SyntaxWarning, MyCapytainException):
""" Error generated when a duplicate is found in CtsReference
"""
class RefsDeclError(Exception, MyCapytainException):
""" Error issued when an the refsDecl does not succeed in xpath (no results)
"""
pass
class InvalidSiblingRequest(Exception, MyCapytainException):
""" This error is thrown when one attempts to get previous or next passage on a passage with a range of different
depth, ex. : 1-2.25
"""
pass
class InvalidURN(Exception, MyCapytainException):
""" This error is thrown when URN are not valid
"""
class MissingAttribute(Exception, MyCapytainException):
""" This error is thrown when an attribute is not present in the Object (missing at startup)
"""
class UnknownObjectError(ValueError, MyCapytainException):
""" This error is thrown when an object does not exist in an inventory or in an API
"""
class UnknownNamespace(ValueError, MyCapytainException):
""" This error is thrown when a namespace is unknown
"""
class UndispatchedTextError(Exception, MyCapytainException):
""" This error is thrown when a text has not been dispatched by a dispatcher
"""
class UnknownCollection(KeyError, MyCapytainException):
""" A collection is unknown to its ancestor
"""
class EmptyReference(SyntaxWarning, MyCapytainException):
""" Error generated when a CtsReference does not exist or is invalid
"""
class CitationDepthError(UnknownObjectError, MyCapytainException):
""" Error generated when the depth of a requested citation is deeper than the citation scheme of the text
"""
class MissingRefsDecl(Exception, MyCapytainException):
""" A text has no properly encoded refsDecl
"""
class PaginationBrowsingError(MyCapytainException):
""" When contacting a remote service and some part of the pages where not reachable or parsable
"""
class CapitainsXPathError(Exception):
def __init__(self, message):
super(CapitainsXPathError, self).__init__()
self.message = message
def __repr__(self):
return "CapitainsXPathError("+self.message+")"