-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy patherror.py
58 lines (40 loc) · 1.36 KB
/
error.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
"""
.. codeauthor:: Tsuyoshi Hombashi <[email protected]>
"""
import sqlite3
from typing import Any, Optional
from tabledata import NameValidationError # noqa: F401
class DatabaseError(sqlite3.DatabaseError):
"""
Exception raised for errors that are related to the database.
.. seealso::
- `sqlite3.DatabaseError <https://docs.python.org/3/library/sqlite3.html#sqlite3.DatabaseError>`__
"""
class NullDatabaseConnectionError(DatabaseError):
"""
Exception raised when executing an operation of
:py:class:`~simplesqlite.SimpleSQLite` instance without connection to
a SQLite database file.
"""
class TableNotFoundError(DatabaseError):
"""
Exception raised when accessed the table that not exists in the database.
"""
class AttributeNotFoundError(DatabaseError):
"""
Exception raised when accessed the attribute that not exists in the table.
"""
class SqlSyntaxError(Exception):
"""
Exception raised when a SQLite query syntax is invalid.
"""
class OperationalError(sqlite3.OperationalError):
"""
Exception raised when failed to execute a query.
"""
@property
def message(self) -> Optional[str]:
return self.__message
def __init__(self, *args: Any, **kwargs: Any) -> None:
self.__message = kwargs.pop("message", None)
super().__init__(*args)