src/rdflib/exceptions.py
1"""
2TODO:
3"""
4
5from __future__ import annotations
6
7__all__ = [
8 "Error",
9 "ParserError",
10 "UniquenessError",
11]
12
13
14from typing import Any, Optional
15
16
17class Error(Exception):
18 """Base class for rdflib exceptions."""
19
20 def __init__(self, msg: Optional[str] = None):
21 Exception.__init__(self, msg)
22 self.msg = msg
23
24
25class ParserError(Error):
26 """RDF Parser error."""
27
28 def __init__(self, msg: str):
29 Error.__init__(self, msg)
30 self.msg: str = msg
31
32 def __str__(self) -> str:
33 return self.msg
34
35
36class UniquenessError(Error):
37 """A uniqueness assumption was made in the context, and that is not true"""
38
39 def __init__(self, values: Any):
40 Error.__init__(
41 self,
42 "\
43Uniqueness assumption is not fulfilled. Multiple values are: %s"
44 % values,
45 )