Skip to content

Commit

Permalink
2.0.0b8
Browse files Browse the repository at this point in the history
- Collection[InvalidId] now raises UnknownCollection [ Fixed #113 ]
- MyCapytain Errors are now decendent of MyCapytainException
  • Loading branch information
PonteIneptique committed Feb 17, 2017
1 parent a80e99a commit da85530
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MyCapytain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"""

__version__ = "2.0.0b7"
__version__ = "2.0.0b8"
26 changes: 18 additions & 8 deletions MyCapytain/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,54 @@
"""


class DuplicateReference(SyntaxWarning):
class MyCapytainException(BaseException):
""" Namespacing errors
"""


class DuplicateReference(SyntaxWarning, MyCapytainException):
""" Error generated when a duplicate is found in Reference
"""


class RefsDeclError(Exception):
class RefsDeclError(Exception, MyCapytainException):
""" Error issued when an the refsDecl does not succeed in xpath (no results)
"""
pass


class InvalidSiblingRequest(Exception):
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):
class InvalidURN(Exception, MyCapytainException):
""" This error is thrown when URN are not valid
"""


class MissingAttribute(Exception):
class MissingAttribute(Exception, MyCapytainException):
""" This error is thrown when an attribute is not present in the Object (missing at startup)
"""


class UnknownObjectError(ValueError):
class UnknownObjectError(ValueError, MyCapytainException):
""" This error is thrown when an object does not exist in an inventory or in an API
"""


class UnknownNamespace(ValueError):
class UnknownNamespace(ValueError, MyCapytainException):
""" This error is thrown when a namespace is unknown
"""


class UndispatchedTextError(Exception):
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
"""
3 changes: 2 additions & 1 deletion MyCapytain/resources/prototypes/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

from MyCapytain.common.metadata import Metadata
from MyCapytain.errors import UnknownCollection
from MyCapytain.common.utils import Subgraph, LiteralToDict
from MyCapytain.common.constants import NAMESPACES, RDFLIB_MAPPING, Mimetypes, Exportable, GRAPH
from rdflib import URIRef, RDF, Literal, Graph, RDFS
Expand Down Expand Up @@ -208,7 +209,7 @@ def __getitem__(self, item):
for obj in self.descendants + [self]:
if obj.id == item:
return obj
raise KeyError("%s is not part of this object" % item)
raise UnknownCollection("%s is not part of this object" % item)

def __contains__(self, item):
""" Retrieve an item by its ID in the tree of a collection
Expand Down

0 comments on commit da85530

Please sign in to comment.