Repository navigation
Expand file tree
/
Copy pathexceptions.py
More file actions
52 lines (38 loc) · 1.75 KB
/
Copy pathexceptions.py
File metadata and controls
52 lines (38 loc) · 1.75 KB
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
class PyOpenMLError(Exception):
def __init__(self, message):
self.message = message
super(PyOpenMLError, self).__init__(message)
class OpenMLServerError(PyOpenMLError):
"""class for when something is really wrong on the server
(result did not parse to dict), contains unparsed error."""
def __init__(self, message):
super(OpenMLServerError, self).__init__(message)
class OpenMLServerException(OpenMLServerError):
"""exception for when the result of the server was
not 200 (e.g., listing call w/o results). """
# Code needs to be optional to allow the exceptino to be picklable:
# https://stackoverflow.com/questions/16244923/how-to-make-a-custom-exception-class-with-multiple-init-args-pickleable
def __init__(self, message, code=None, additional=None, url=None):
self.message = message
self.code = code
self.additional = additional
self.url = url
super(OpenMLServerException, self).__init__(message)
def __str__(self):
return '%s returned code %s: %s' % (
self.url, self.code, self.message,
)
class OpenMLServerNoResult(OpenMLServerException):
"""exception for when the result of the server is empty. """
pass
class OpenMLCacheException(PyOpenMLError):
"""Dataset / task etc not found in cache"""
def __init__(self, message):
super(OpenMLCacheException, self).__init__(message)
class OpenMLHashException(PyOpenMLError):
"""Locally computed hash is different than hash announced by the server."""
pass
class PrivateDatasetError(PyOpenMLError):
"Exception thrown when the user has no rights to access the dataset"
def __init__(self, message):
super(PrivateDatasetError, self).__init__(message)