forked from orbingol/NURBS-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
40 lines (29 loc) · 979 Bytes
/
exceptions.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
"""
.. module:: exceptions
:platform: Unix, Windows
:synopsis: Defines custom exceptions
.. moduleauthor:: Onur Rauf Bingol <orbingol@gmail.com>
"""
from ._utilities import export
ERROR_PREFIX = "GEOMDL ERROR: "
@export
class GeomdlException(Exception):
""" Custom exception for controlling geometric errors.
The error details can be retrieved by querying ``data`` class member. The following snippet illustrates a sample
usage of this exception.
.. code-example: python
from geomdl import exceptions
DEBUG = True
# Catch the exception
try:
# Do something which can raise this exception
except GeomdlException as e:
print(e)
if DEBUG:
print(e.data)
# Stop execution of the function
return
"""
def __init__(self, msg, data=None):
super(GeomdlException, self).__init__(ERROR_PREFIX + msg)
self.data = data