-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy patherrors.py
94 lines (65 loc) · 2.13 KB
/
errors.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""
Module defines errors used in this library.
"""
from typing import Set
from ..errors import DataprepError
class RequestError(DataprepError):
"""
A error indicating the status code of the API response
is not 200.
"""
status_code: int
message: str
def __init__(self, status_code: int, message: str) -> None:
"""
Constructor
parameters
----------
status_code : int
The http status code
messsage : str
The message from the response
"""
super().__init__()
self.status_code = status_code
self.message = message
def __str__(self) -> str:
return f"RequestError: status={self.status_code}, message={self.message}"
class UniversalParameterOverridden(Exception):
"""
The parameter is overrided by the universal parameter
"""
param: str
uparam: str
def __init__(self, param: str, uparam: str) -> None:
super().__init__()
self.param = param
self.uparam = uparam
def __str__(self) -> str:
return f"the parameter {self.param} is overridden by {self.uparam}"
class InvalidParameterError(Exception):
"""
The parameter used in the query is invalid
"""
param: str
def __init__(self, param: str) -> None:
super().__init__()
self.param = param
def __str__(self) -> str:
return f"the parameter {self.param} is invalid, refer info method"
class MissingRequiredAuthParams(ValueError):
"""Some parameters for Authorization are missing."""
params: Set[str]
def __init__(self, params: Set[str]) -> None:
super().__init__()
self.params = params
def __str__(self) -> str:
return f"Missing required authorization parameter(s) {self.params} in _auth"
class InvalidAuthParams(ValueError):
"""The parameters used for Authorization are invalid."""
params: Set[str]
def __init__(self, params: Set[str]) -> None:
super().__init__()
self.params = params
def __str__(self) -> str:
return f"Authorization parameter(s) {self.params} in _auth are not required."