OmniSciDB
94e8789169
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
exceptions.py
Go to the documentation of this file.
1
"""
2
Define exceptions as specified by the DB API 2.0 spec.
3
4
Includes some helper methods for translating thrift
5
exceptions to the ones defined here.
6
"""
7
from
omnisci.thrift.ttypes
import
TOmniSciException
8
9
10
class
Warning
(Exception):
11
"""Emitted for important warnings, e.g. data truncatiions"""
12
13
14
class
Error
(Exception):
15
"""Base class for all pymapd errors."""
16
17
18
class
InterfaceError
(
Error
):
19
"""Raised whenever you use pymapd interface incorrectly."""
20
21
22
class
DatabaseError
(
Error
):
23
"""Raised when the database encounters an error."""
24
25
26
class
DataError
(
DatabaseError
):
27
"""Raised for data processing errors like division by zero, etc."""
28
29
30
class
OperationalError
(
DatabaseError
):
31
"""Raised for non-programmer related database errors, e.g.
32
an unexpected disconnect.
33
"""
34
35
36
class
IntegrityError
(
DatabaseError
):
37
"""Raised when the relational integrity of the database is affected."""
38
39
40
class
InternalError
(
DatabaseError
):
41
"""Raised for errors internal to the database, e.g. and invalid cursor."""
42
43
44
class
ProgrammingError
(
DatabaseError
):
45
"""Raised for programming errors, e.g. syntax errors, table already
46
exists.
47
"""
48
49
50
class
NotSupportedError
(
DatabaseError
):
51
"""Raised when an API not supported by the database is used."""
52
53
54
def
_translate_exception
(e):
55
# type: (Exception) -> Exception
56
"""Translate a thrift-land exception to a DB-API 2.0
57
exception.
58
"""
59
# TODO: see if there's a way to get error codes, rather than relying msgs
60
if
not
isinstance(e, TOmniSciException):
61
return
e
62
if
'Validate failed'
in
e.error_msg
or
'Parse failed'
in
e.error_msg:
63
err = ProgrammingError
64
elif
'Exception occurred'
in
e.error_msg:
65
err = DatabaseError
66
else
:
67
err = Error
68
return
err(e.error_msg)
omnisci.exceptions.InternalError
Definition:
exceptions.py:40
omnisci.exceptions._translate_exception
def _translate_exception
Definition:
exceptions.py:54
omnisci.exceptions.ProgrammingError
Definition:
exceptions.py:44
omnisci.exceptions.IntegrityError
Definition:
exceptions.py:36
omnisci.exceptions.OperationalError
Definition:
exceptions.py:30
omnisci.exceptions.Error
Definition:
exceptions.py:14
omnisci.exceptions.NotSupportedError
Definition:
exceptions.py:50
omnisci.exceptions.DatabaseError
Definition:
exceptions.py:22
omnisci.exceptions.Warning
Definition:
exceptions.py:10
omnisci.exceptions.InterfaceError
Definition:
exceptions.py:18
omnisci.exceptions.DataError
Definition:
exceptions.py:26
omnisci.thrift.ttypes
Definition:
ttypes.py:1
python
omnisci
exceptions.py
Generated on Tue Feb 16 2021 13:11:29 for OmniSciDB by
1.8.5