-
Notifications
You must be signed in to change notification settings - Fork 1
/
exceptions.py
56 lines (38 loc) · 1.45 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import dill
from tblib import Traceback
from functools import wraps
from six import reraise
# Credit: Schema for errors borrowed from the Parsl Project.
# Link: https://github.com/Parsl/parsl/blob/bd5354d0381d45f390bd11cf16c150dee612c325/parsl/app/errors.py#L109
class XtractError(Exception):
""" Base class for all exceptions.
Only to be invoked when a more specific error is not available.
"""
class HttpsDownloadTimeout(Exception):
""" A file did not reach the compute resource within n seconds, if
user set timeout=n
"""
class ExtractorError(XtractError):
""" The extractor did not successfully complete due to extractor file """
class PetrelRetrievalError(Exception):
""" We were unable to successfully connect or retrieve file from Petrel"""
class RemoteExceptionWrapper:
def __init__(self, e_type, e_value, traceback):
self.e_type = dill.dumps(e_type)
self.e_value = dill.dumps(e_value)
self.e_traceback = Traceback(traceback)
def reraise(self):
t = dill.loads(self.e_type)
v = dill.loads(self.e_value)
tb = self.e_traceback.as_traceback()
reraise(t, v, tb)
def wrap_error(func):
@wraps(func)
def wrapper(*args, **kwargs):
import sys
from parsl.app.errors import RemoteExceptionWrapper
try:
return func(*args, **kwargs)
except Exception:
return RemoteExceptionWrapper(*sys.exc_info())
return wrapper