Repository navigation
Expand file tree
/
Copy patherrors.py
More file actions
189 lines (179 loc) · 4.81 KB
/
Copy patherrors.py
File metadata and controls
189 lines (179 loc) · 4.81 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
from __future__ import annotations
from typing import Any, Literal
LinkedApiActionErrorType = Literal[
"personNotFound",
"selfProfileNotAllowed",
"personLikelyChangedPublicUrl",
"messagingNotAllowed",
"alreadyPending",
"alreadyConnected",
"emailRequired",
"noteTooLong",
"noteLimitExceeded",
"invitationAlreadyReceived",
"requestNotAllowed",
"notPending",
"noPendingRequest",
"retrievingNotAllowed",
"connectionNotFound",
"skillNotFound",
"endorsementUnavailable",
"limitExceeded",
"searchingNotAllowed",
"searchInterfaceMismatch",
"searchTemporarilyUnavailable",
"filterNotApplied",
"companyNotFound",
"postNotFound",
"jobNotFound",
"commentingNotAllowed",
"commentNotFound",
"replyingNotAllowed",
"duplicateComment",
"noPostingPermission",
"textTooLong",
"unsupportedAttachmentType",
"missingDocumentName",
"urlNotAccessible",
"fileTooLarge",
"unsupportedMimeType",
"tooManyAttachments",
"mixingNotAllowed",
"mentionNotResolved",
"repostNotAllowed",
"alreadyReposted",
"noSalesNavigator",
"salesNavigatorOnboardingRequired",
"conversationsNotSynced",
"threadNotFound",
"ssiNotAvailable",
"unexpectedError",
]
LINKED_API_ACTION_ERROR_TYPES: tuple[str, ...] = (
"personNotFound",
"selfProfileNotAllowed",
"personLikelyChangedPublicUrl",
"messagingNotAllowed",
"alreadyPending",
"alreadyConnected",
"emailRequired",
"noteTooLong",
"noteLimitExceeded",
"invitationAlreadyReceived",
"requestNotAllowed",
"notPending",
"noPendingRequest",
"retrievingNotAllowed",
"connectionNotFound",
"skillNotFound",
"endorsementUnavailable",
"limitExceeded",
"searchingNotAllowed",
"searchInterfaceMismatch",
"searchTemporarilyUnavailable",
"filterNotApplied",
"companyNotFound",
"postNotFound",
"jobNotFound",
"commentingNotAllowed",
"commentNotFound",
"replyingNotAllowed",
"duplicateComment",
"noPostingPermission",
"textTooLong",
"unsupportedAttachmentType",
"missingDocumentName",
"urlNotAccessible",
"fileTooLarge",
"unsupportedMimeType",
"tooManyAttachments",
"mixingNotAllowed",
"mentionNotResolved",
"repostNotAllowed",
"alreadyReposted",
"noSalesNavigator",
"salesNavigatorOnboardingRequired",
"conversationsNotSynced",
"threadNotFound",
"ssiNotAvailable",
"unexpectedError",
)
LinkedApiErrorType = Literal[
"linkedApiTokenRequired",
"invalidLinkedApiToken",
"identificationTokenRequired",
"invalidIdentificationToken",
"subscriptionRequired",
"trialLimitReached",
"invalidRequestPayload",
"invalidWorkflow",
"plusPlanRequired",
"linkedinAccountSignedOut",
"languageNotSupported",
"workflowTimeout",
"outsideWorkingHours",
"workingHoursWaitExpired",
"cancelledByUser",
"unexpectedError",
"httpError",
"tooManyRequests",
"accountNotFound",
"accountIdRequired",
"sessionNotFound",
"noAvailableSeats",
"dailyConnectionAttemptsExceeded",
]
LINKED_API_ERROR_TYPES: tuple[str, ...] = (
"linkedApiTokenRequired",
"invalidLinkedApiToken",
"identificationTokenRequired",
"invalidIdentificationToken",
"subscriptionRequired",
"trialLimitReached",
"invalidRequestPayload",
"invalidWorkflow",
"plusPlanRequired",
"linkedinAccountSignedOut",
"languageNotSupported",
"workflowTimeout",
"outsideWorkingHours",
"workingHoursWaitExpired",
"cancelledByUser",
"unexpectedError",
"httpError",
"tooManyRequests",
"accountNotFound",
"accountIdRequired",
"sessionNotFound",
"noAvailableSeats",
"dailyConnectionAttemptsExceeded",
)
class LinkedApiError(Exception):
type: str
message: str
details: Any | None
def __init__(self, type: str, message: str, details: Any | None = None) -> None:
super().__init__(message)
self.type = type
self.message = message
self.details = details
@classmethod
def unknown_error(
cls, message: str = "Unknown error. Please contact support."
) -> LinkedApiError:
return cls("unknownError", message)
class LinkedApiWorkflowTimeoutError(LinkedApiError):
workflow_id: str
operation_name: str
def __init__(self, workflow_id: str, operation_name: str) -> None:
message = (
f"Workflow {workflow_id} timed out. Call {operation_name}.result() again to continue "
"checking the workflow."
)
super().__init__(
"workflowTimeout",
message,
{"workflowId": workflow_id, "operationName": operation_name},
)
self.workflow_id = workflow_id
self.operation_name = operation_name