Repository navigation
Expand file tree
/
Copy patherrors.ts
More file actions
126 lines (119 loc) · 5 KB
/
Copy patherrors.ts
File metadata and controls
126 lines (119 loc) · 5 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
import { TOperationName } from '../core';
/**
* This error is exposed when a workflow action fails to complete.
* @see {@link https://linkedapi.io/docs/actions-overview/#result-options}
* This error signals that the workflow action failed to complete, but the workflow completed as expected.
* Common types:
* - personNotFound (sendMessage, syncConversation, checkConnectionStatus, sendConnectionRequest, withdrawConnectionRequest, removeConnection, fetchPerson, nvSendMessage, nvSyncConversation, nvFetchPerson)
* - selfProfileNotAllowed (fetchPerson, nvFetchPerson)
* - messagingNotAllowed (sendMessage, nvSendMessage)
* - alreadyPending (sendConnectionRequest)
* - alreadyConnected (sendConnectionRequest)
* - emailRequired (sendConnectionRequest)
* - noteTooLong (sendConnectionRequest)
* - noteLimitExceeded (sendConnectionRequest)
* - requestNotAllowed (sendConnectionRequest)
* - notPending (withdrawConnectionRequest))
* - retrievingNotAllowed (retrieveConnections, fetchCompany, nvFetchCompany)
* - connectionNotFound (removeConnection)
* - searchingNotAllowed (searchCompanies, searchPeople, searchJobs, nvSearchCompanies, nvSearchPeople)
* - companyNotFound (fetchCompany, nvFetchCompany)
* - postNotFound (fetchPost, reactToPost, commentOnPost)
* - jobNotFound (fetchJob)
* - commentingNotAllowed (commentOnPost)
* - noPostingPermission (createPost, reactToPost, commentOnPost)
* - noSalesNavigator (nvSendMessage, nvSyncConversation, nvSyncInbox, nvSearchCompanies, nvSearchPeople, nvFetchCompany, nvFetchPerson, nvManageConversation)
* - conversationsNotSynced (pollConversations)
* - threadNotFound (manageConversation, nvManageConversation)
*/
export const LINKED_API_ACTION_ERROR = {
personNotFound: 'personNotFound',
selfProfileNotAllowed: 'selfProfileNotAllowed',
messagingNotAllowed: 'messagingNotAllowed',
alreadyPending: 'alreadyPending',
alreadyConnected: 'alreadyConnected',
emailRequired: 'emailRequired',
noteTooLong: 'noteTooLong',
noteLimitExceeded: 'noteLimitExceeded',
requestNotAllowed: 'requestNotAllowed',
notPending: 'notPending',
retrievingNotAllowed: 'retrievingNotAllowed',
connectionNotFound: 'connectionNotFound',
searchingNotAllowed: 'searchingNotAllowed',
companyNotFound: 'companyNotFound',
postNotFound: 'postNotFound',
jobNotFound: 'jobNotFound',
commentingNotAllowed: 'commentingNotAllowed',
noPostingPermission: 'noPostingPermission',
noSalesNavigator: 'noSalesNavigator',
conversationsNotSynced: 'conversationsNotSynced',
threadNotFound: 'threadNotFound',
} as const;
export type TLinkedApiActionErrorType =
(typeof LINKED_API_ACTION_ERROR)[keyof typeof LINKED_API_ACTION_ERROR];
export interface TLinkedApiActionError {
type: TLinkedApiActionErrorType;
message: string;
}
/**
* This error is thrown when a request fails.
* @see {@link https://linkedapi.io/docs/making-requests/#common-errors}
*/
export const LINKED_API_ERROR = {
linkedApiTokenRequired: 'linkedApiTokenRequired',
invalidLinkedApiToken: 'invalidLinkedApiToken',
identificationTokenRequired: 'identificationTokenRequired',
invalidIdentificationToken: 'invalidIdentificationToken',
subscriptionRequired: 'subscriptionRequired',
trialLimitReached: 'trialLimitReached',
invalidRequestPayload: 'invalidRequestPayload',
invalidWorkflow: 'invalidWorkflow',
plusPlanRequired: 'plusPlanRequired',
linkedinAccountSignedOut: 'linkedinAccountSignedOut',
languageNotSupported: 'languageNotSupported',
workflowTimeout: 'workflowTimeout',
httpError: 'httpError',
tooManyRequests: 'tooManyRequests',
accountNotFound: 'accountNotFound',
accountIdRequired: 'accountIdRequired',
sessionNotFound: 'sessionNotFound',
noAvailableSeats: 'noAvailableSeats',
dailyConnectionAttemptsExceeded: 'dailyConnectionAttemptsExceeded',
} as const;
export type TLinkedApiErrorType = (typeof LINKED_API_ERROR)[keyof typeof LINKED_API_ERROR];
export class LinkedApiError extends Error {
public type: TLinkedApiErrorType;
public override message: string;
public details?: unknown;
constructor(type: TLinkedApiErrorType, message: string, details?: unknown) {
super(message);
this.type = type;
this.message = message;
this.details = details;
}
public static unknownError(
message: string = 'Unknown error. Please contact support.',
): LinkedApiError {
return new LinkedApiError('unknownError' as TLinkedApiErrorType, message);
}
}
/**
* This error is thrown when a workflow times out.
* Contains workflowId and operationName to continue checking the workflow.
*/
export class LinkedApiWorkflowTimeoutError extends LinkedApiError {
public readonly workflowId: string;
public readonly operationName: TOperationName;
constructor(workflowId: string, operationName: TOperationName) {
super(
'workflowTimeout',
`Workflow ${workflowId} timed out. Call ${operationName}.result() again to continue checking the workflow.`,
{
workflowId,
operationName,
},
);
this.workflowId = workflowId;
this.operationName = operationName;
}
}