forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudException.py
More file actions
29 lines (25 loc) · 761 Bytes
/
Copy pathcloudException.py
File metadata and controls
29 lines (25 loc) · 761 Bytes
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
import sys
import traceback
class CloudRuntimeException(Exception):
def __init__(self, errMsg):
self.errMsg = errMsg
value = sys.exc_info()[1]
if value is not None:
self.errMsg += ", due to:" + str(value)
self.details = formatExceptionInfo()
def __str__(self):
return self.errMsg
def getDetails(self):
return self.details
class CloudInternalException(Exception):
def __init__(self, errMsg):
self.errMsg = errMsg
def __str__(self):
return self.errMsg
def formatExceptionInfo(maxTBlevel=5):
cla, exc, trbk = sys.exc_info()
excTb = traceback.format_tb(trbk, maxTBlevel)
msg = str(exc) + "\n"
for tb in excTb:
msg += tb
return msg