conductor-node 9.0.2 → 9.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -51
- package/dist/package.json +1 -1
- package/dist/src/error.d.ts +41 -23
- package/dist/src/error.js +47 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,28 +116,28 @@ Checks whether the specified integration-connection can connect and process requ
|
|
|
116
116
|
|
|
117
117
|
If the connection fails, the error we encountered will be thrown as a [`ConductorError`](#error-handling). This information is useful for showing a "connection status" indicator in your app. If an error occurs, we recommend displaying the property `error.endUserMessage` to your end-user in your app's UI.
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
Using `async`/`await`:
|
|
120
120
|
|
|
121
121
|
```ts
|
|
122
|
-
|
|
122
|
+
try {
|
|
123
|
+
await conductor.pingIntegrationConnection(qbdConnectionId);
|
|
124
|
+
} catch (error) {
|
|
123
125
|
if (error instanceof ConductorError) {
|
|
124
126
|
// Update your app's UI to display `error.endUserMessage`.
|
|
125
127
|
}
|
|
126
128
|
// ...
|
|
127
|
-
}
|
|
129
|
+
}
|
|
128
130
|
```
|
|
129
131
|
|
|
130
|
-
Or
|
|
132
|
+
Or in the form of a rejected promise:
|
|
131
133
|
|
|
132
134
|
```ts
|
|
133
|
-
|
|
134
|
-
await conductor.pingIntegrationConnection(qbdConnectionId);
|
|
135
|
-
} catch (error) {
|
|
135
|
+
conductor.pingIntegrationConnection(qbdConnectionId).catch((error) => {
|
|
136
136
|
if (error instanceof ConductorError) {
|
|
137
137
|
// Update your app's UI to display `error.endUserMessage`.
|
|
138
138
|
}
|
|
139
139
|
// ...
|
|
140
|
-
}
|
|
140
|
+
});
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
## TypeScript
|
|
@@ -160,34 +160,53 @@ const accountAddInput: QbdTypes.AccountAdd = {
|
|
|
160
160
|
|
|
161
161
|
### `ConductorError`
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
All errors thrown by the Conductor API are instances of `ConductorError` or its subclasses. These errors have the following properties:
|
|
164
164
|
|
|
165
|
-
| Property | Type | Description
|
|
166
|
-
| ----------------- | ----------------------- |
|
|
167
|
-
| `type` | `string` |
|
|
168
|
-
| `code` | `string` | The unique error code from Conductor, which is useful for adding special handling for specific errors. E.g., `"INTEGRATION_CONNECTION_MISSING"`, `"API_KEY_INVALID"`, or `"QBD_REQUEST_ERROR"`.<br><br>
|
|
169
|
-
| `message` | `string` | The developer-friendly error message for your logs.
|
|
170
|
-
| `endUserMessage` | `string` | The end-user-friendly error message to display in your app's UI
|
|
171
|
-
| `integrationCode` | `string` or `undefined` | The unique error code supplied by the third-party integration for errors
|
|
172
|
-
| `httpStatusCode` | `number` or `undefined` | The HTTP status code of the response that included the error. You probably won't need this.
|
|
165
|
+
| Property | Type | Description |
|
|
166
|
+
| ----------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
167
|
+
| `type` | `string` | Categorizes the error. See [Error Types](#error-types) below.<br><br>This value is the same as the subclass name. E.g., `"ConductorIntegrationError"` or `"ConductorInvalidRequestError"`. |
|
|
168
|
+
| `code` | `string` | The unique error code from Conductor, which is useful for adding special handling for specific errors. E.g., `"INTEGRATION_CONNECTION_MISSING"`, `"API_KEY_INVALID"`, or `"QBD_REQUEST_ERROR"`.<br><br>In contrast, `type` is more general and categorizes the error. |
|
|
169
|
+
| `message` | `string` | The developer-friendly error message for your logs. |
|
|
170
|
+
| `endUserMessage` | `string` | The end-user-friendly error message to display in your app's UI to your end-users.<br><br>This value exists for _every_ error. E.g., for a QBD connection error, it might recommend the end-user to check that their QuickBooks Desktop is open and that they're logged in. But if a Conductor API key is expired, e.g., this message will just say "An internal server error occurred. Please try again later.". |
|
|
171
|
+
| `integrationCode` | `string` or `undefined` | The unique error code supplied by the third-party integration for errors returned by the integration (i.e., `ConductorIntegrationError`) or integration connector (i.e., `ConductorIntegrationConnectorError`). This is useful for adding special handling for specific errors from the third-party integration or connector.<br><br>The integration's corresponding error message for this code is in `error.message`.<br><br>The third-party integrations' error codes are not standardized, so you should not rely on this code to be the same across integrations. |
|
|
172
|
+
| `httpStatusCode` | `number` or `undefined` | The HTTP status code of the response that included the error. You probably won't need this. |
|
|
173
173
|
|
|
174
174
|
### Error Types
|
|
175
175
|
|
|
176
176
|
The error object you receive will have one of the following error types:
|
|
177
177
|
|
|
178
|
-
| Type
|
|
179
|
-
|
|
|
180
|
-
| `ConductorIntegrationError`
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
183
|
-
| `
|
|
184
|
-
| `
|
|
178
|
+
| Type | Description |
|
|
179
|
+
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
180
|
+
| `ConductorIntegrationError` | Raised when the third-party integration returned an error while processing your end-user's request. This is likely due to an issue with your request or data handling that you must fix.<br><br>E.g., a `ListID` you provided was not found in QuickBooks Desktop, or an accounting value you provided failed the integration's accounting rules.<br><br>See `error.integrationCode` (above) for the error code that the integration returned, if any. |
|
|
181
|
+
| `ConductorIntegrationConnectionError` | Raised when an error occurred connecting to the third-party integration on behalf of the end-user. Most likely, something is wrong with the end-user's integration connection or configuration that _the end-user must fix_, not you. <br><br>E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop on the end-user's computer.<br><br>See `error.integrationCode` (above) for the error code that the integration connector returned, if any.<br><br>❗ We recommend _not_ alerting your team for these errors because only the end-user can fix them. See [Global Error Handling](#global-error-handling) for an example of this. |
|
|
182
|
+
| `ConductorInvalidRequestError` | Raised when you make an API call with the wrong parameters, in the wrong state, or in an invalid way. |
|
|
183
|
+
| `ConductorAuthenticationError` | Raised when Conductor cannot authenticate you with the credentials you provided. E.g., an incorrect API key. |
|
|
184
|
+
| `ConductorConnectionError` | Raised when there was a network problem between the client (on your server) and Conductor's servers. E.g., a downed network or a bad TLS certificate. |
|
|
185
|
+
| `ConductorInternalError` | Raised when something went wrong on Conductor's end. (These are rare.) |
|
|
185
186
|
|
|
186
187
|
### Specific Error Handling
|
|
187
188
|
|
|
188
189
|
If you need special handling for specific errors, you can wrap individual API calls, as shown below.
|
|
189
190
|
|
|
190
|
-
|
|
191
|
+
Using `async`/`await`:
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
try {
|
|
195
|
+
const newAccount = await conductor.qbd.account.add(qbdConnectionId, {
|
|
196
|
+
Name: "Test Account",
|
|
197
|
+
AccountType: "Bank",
|
|
198
|
+
OpenBalance: "100",
|
|
199
|
+
});
|
|
200
|
+
} catch (error) {
|
|
201
|
+
if (error instanceof ConductorError) {
|
|
202
|
+
// Check `error.code`, `error.integrationCode`, etc., for special handling.
|
|
203
|
+
} else {
|
|
204
|
+
// ...
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Or in the form of a rejected promise:
|
|
191
210
|
|
|
192
211
|
```ts
|
|
193
212
|
conductor.qbd.account
|
|
@@ -208,45 +227,34 @@ conductor.qbd.account
|
|
|
208
227
|
});
|
|
209
228
|
```
|
|
210
229
|
|
|
211
|
-
Or using `async`/`await`:
|
|
212
|
-
|
|
213
|
-
```ts
|
|
214
|
-
try {
|
|
215
|
-
const newAccount = await conductor.qbd.account.add(qbdConnectionId, {
|
|
216
|
-
Name: "Test Account",
|
|
217
|
-
AccountType: "Bank",
|
|
218
|
-
OpenBalance: "100",
|
|
219
|
-
});
|
|
220
|
-
} catch (error) {
|
|
221
|
-
if (error instanceof ConductorError) {
|
|
222
|
-
// Check `error.code`, `error.integrationCode`, etc., for special handling.
|
|
223
|
-
} else {
|
|
224
|
-
// ...
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
```
|
|
228
|
-
|
|
229
230
|
### Global Error Handling
|
|
230
231
|
|
|
231
232
|
We do _not_ expect you to individually wrap every API call like the examples above. Instead, we recommend your server use a single global error handler, such as [`app.use((error, ...) => { ... })` in Express](https://expressjs.com/en/guide/error-handling.html#writing-error-handlers) or [`formatError` in Apollo Server](https://apollographql.com/docs/apollo-server/data/errors/#for-client-responses), where you do the following:
|
|
232
233
|
|
|
233
234
|
1. Ensure your app's UI shows your end-user the property `error.endUserMessage` for any `ConductorError` instance while you log the rest of the error object.
|
|
234
235
|
2. Send the entire error object to your error-tracking service (e.g., Sentry) for all `ConductorError` instances:
|
|
235
|
-
- Send a **warning** for instances of `
|
|
236
|
+
- Send a **warning** for instances of `ConductorIntegrationConnectionError`, which only the end-user can fix; e.g., failed to connect to QuickBooks Desktop on your end-user's computer.
|
|
236
237
|
- Send an **error** for all other `ConductorError` instances; e.g., invalid API key.
|
|
237
238
|
|
|
238
239
|
For example, using an Express error handler:
|
|
239
240
|
|
|
240
241
|
```ts
|
|
241
242
|
import * as Sentry from "@sentry/node";
|
|
242
|
-
import {
|
|
243
|
+
import {
|
|
244
|
+
ConductorError,
|
|
245
|
+
ConductorIntegrationConnectionError,
|
|
246
|
+
} from "conductor-node";
|
|
243
247
|
// ...
|
|
244
248
|
app.use((error, req, res, next) => {
|
|
245
249
|
if (error instanceof ConductorError) {
|
|
246
250
|
Sentry.captureException(error, {
|
|
247
|
-
level:
|
|
251
|
+
level:
|
|
252
|
+
error instanceof ConductorIntegrationConnectionError
|
|
253
|
+
? "warning"
|
|
254
|
+
: "error",
|
|
248
255
|
});
|
|
249
|
-
// Return a different error message for your end-user to see in your
|
|
256
|
+
// Return a different error message for your end-user to see in your
|
|
257
|
+
// app's UI.
|
|
250
258
|
res.status(500).send({ error: { message: error.endUserMessage } });
|
|
251
259
|
} else {
|
|
252
260
|
// ...
|
|
@@ -260,7 +268,10 @@ Or using Apollo Server's error handler:
|
|
|
260
268
|
import { ApolloServer } from "@apollo/server";
|
|
261
269
|
import { unwrapResolverError } from "@apollo/server/errors";
|
|
262
270
|
import * as Sentry from "@sentry/node";
|
|
263
|
-
import {
|
|
271
|
+
import {
|
|
272
|
+
ConductorError,
|
|
273
|
+
ConductorIntegrationConnectionError,
|
|
274
|
+
} from "conductor-node";
|
|
264
275
|
// ...
|
|
265
276
|
const server = new ApolloServer({
|
|
266
277
|
// ...
|
|
@@ -269,7 +280,9 @@ const server = new ApolloServer({
|
|
|
269
280
|
if (origError instanceof ConductorError) {
|
|
270
281
|
Sentry.captureException(origError, {
|
|
271
282
|
level:
|
|
272
|
-
origError instanceof
|
|
283
|
+
origError instanceof ConductorIntegrationConnectionError
|
|
284
|
+
? "warning"
|
|
285
|
+
: "error",
|
|
273
286
|
});
|
|
274
287
|
return {
|
|
275
288
|
...formattedError,
|
|
@@ -283,5 +296,3 @@ const server = new ApolloServer({
|
|
|
283
296
|
},
|
|
284
297
|
});
|
|
285
298
|
```
|
|
286
|
-
|
|
287
|
-
NOTE: In writing this, I realize that you might want to be alerted for integration errors unrelated to connections, such as QBD failing for accounting reasons. Perhaps I'll add the error type `ConductorIntegrationConnectionError` in the future.
|
package/dist/package.json
CHANGED
package/dist/src/error.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface ConductorGraphqlError {
|
|
|
20
20
|
*/
|
|
21
21
|
export declare class ConductorError extends Error {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Categorizes the error.
|
|
24
24
|
*
|
|
25
25
|
* This value is the same as the subclass name. E.g.,
|
|
26
26
|
* `"ConductorIntegrationError"` or `"ConductorInvalidRequestError"`.
|
|
@@ -31,7 +31,7 @@ export declare class ConductorError extends Error {
|
|
|
31
31
|
* handling for specific errors. E.g., `"INTEGRATION_CONNECTION_MISSING"`,
|
|
32
32
|
* `"API_KEY_INVALID"`, or `"QBD_REQUEST_ERROR"`.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
34
|
+
* In contrast, `type` is more general and categorizes the error.
|
|
35
35
|
*/
|
|
36
36
|
readonly code: string;
|
|
37
37
|
/**
|
|
@@ -39,27 +39,27 @@ export declare class ConductorError extends Error {
|
|
|
39
39
|
*/
|
|
40
40
|
readonly message: string;
|
|
41
41
|
/**
|
|
42
|
-
* The end-user-friendly error message to display in your app's UI
|
|
43
|
-
* end-
|
|
42
|
+
* The end-user-friendly error message to display in your app's UI to your
|
|
43
|
+
* end-users.
|
|
44
44
|
*
|
|
45
|
-
* This value exists for *every* error. E.g.,
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
45
|
+
* This value exists for *every* error. E.g., for a QBD connection error, it
|
|
46
|
+
* might recommend the end-user to check that their QuickBooks Desktop is open
|
|
47
|
+
* and that they're logged in. But if a Conductor API key is expired, e.g.,
|
|
48
|
+
* this message will just say "An internal server error occurred. Please try
|
|
49
|
+
* again later.".
|
|
50
50
|
*/
|
|
51
51
|
readonly endUserMessage: string;
|
|
52
52
|
/**
|
|
53
53
|
* The unique error code supplied by the third-party integration for errors
|
|
54
|
-
*
|
|
55
|
-
* `
|
|
56
|
-
* for specific errors from the third-party
|
|
54
|
+
* returned by the integration (i.e., `ConductorIntegrationError`) or
|
|
55
|
+
* integration connector (i.e., `ConductorIntegrationConnectorError`). This is
|
|
56
|
+
* useful for adding special handling for specific errors from the third-party
|
|
57
|
+
* integration or connector.
|
|
57
58
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* error message for this code is in `error.message`.
|
|
59
|
+
* The integration's corresponding error message for this code is in
|
|
60
|
+
* `error.message`.
|
|
61
61
|
*
|
|
62
|
-
* The third-party
|
|
62
|
+
* The third-party integrations' error codes are not standardized, so you
|
|
63
63
|
* should not rely on this code to be the same across integrations.
|
|
64
64
|
*/
|
|
65
65
|
readonly integrationCode: string | undefined;
|
|
@@ -77,14 +77,32 @@ export declare class ConductorError extends Error {
|
|
|
77
77
|
type ConductorErrorOptionsWithoutType = Omit<ConductorErrorOptions, "type">;
|
|
78
78
|
/**
|
|
79
79
|
* Raised when the third-party integration returned an error while processing
|
|
80
|
-
* your end-user's request.
|
|
81
|
-
*
|
|
80
|
+
* your end-user's request. This is likely due to an issue with your request or
|
|
81
|
+
* data handling that you must fix.
|
|
82
82
|
*
|
|
83
|
-
*
|
|
84
|
-
* integration
|
|
83
|
+
* E.g., a `ListID` you provided was not found in QuickBooks Desktop, or an
|
|
84
|
+
* accounting value you provided failed the integration's accounting rules.
|
|
85
|
+
*
|
|
86
|
+
* See `error.integrationCode` for the error code that the integration returned,
|
|
87
|
+
* if any.
|
|
85
88
|
*/
|
|
86
89
|
export declare class ConductorIntegrationError extends ConductorError {
|
|
87
|
-
static readonly rawType
|
|
90
|
+
static readonly rawType = "INTEGRATION_ERROR";
|
|
91
|
+
constructor(options: ConductorErrorOptionsWithoutType);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Raised when an error occurred connecting to the third-party integration on
|
|
95
|
+
* behalf of the end-user. Most likely, something is wrong with the end-user's
|
|
96
|
+
* integration connection or configuration that the end-user must fix, not you.
|
|
97
|
+
*
|
|
98
|
+
* E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop
|
|
99
|
+
* on the end-user's computer.
|
|
100
|
+
*
|
|
101
|
+
* See `error.integrationCode` for the error code that the integration connector
|
|
102
|
+
* returned, if any.
|
|
103
|
+
*/
|
|
104
|
+
export declare class ConductorIntegrationConnectionError extends ConductorError {
|
|
105
|
+
static readonly rawType = "INTEGRATION_CONNECTION_ERROR";
|
|
88
106
|
constructor(options: ConductorErrorOptionsWithoutType);
|
|
89
107
|
}
|
|
90
108
|
/**
|
|
@@ -104,7 +122,7 @@ export declare class ConductorAuthenticationError extends ConductorError {
|
|
|
104
122
|
constructor(options: ConductorErrorOptionsWithoutType);
|
|
105
123
|
}
|
|
106
124
|
/**
|
|
107
|
-
* Raised when there
|
|
125
|
+
* Raised when there was a network problem between the client (on your server)
|
|
108
126
|
* and Conductor's servers. E.g., a downed network or a bad TLS certificate.
|
|
109
127
|
*/
|
|
110
128
|
export declare class ConductorConnectionError extends ConductorError {
|
|
@@ -112,7 +130,7 @@ export declare class ConductorConnectionError extends ConductorError {
|
|
|
112
130
|
constructor(options: ConductorErrorOptionsWithoutType);
|
|
113
131
|
}
|
|
114
132
|
/**
|
|
115
|
-
* Raised when something
|
|
133
|
+
* Raised when something went wrong on Conductor's end. (These are rare.)
|
|
116
134
|
*/
|
|
117
135
|
export declare class ConductorInternalError extends ConductorError {
|
|
118
136
|
static readonly rawType = "INTERNAL_ERROR";
|
package/dist/src/error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateConductorErrorFromType = exports.ConductorUnknownError = exports.ConductorInternalError = exports.ConductorConnectionError = exports.ConductorAuthenticationError = exports.ConductorInvalidRequestError = exports.ConductorIntegrationError = exports.ConductorError = exports.DEFAULT_END_USER_MESSAGE = void 0;
|
|
3
|
+
exports.generateConductorErrorFromType = exports.ConductorUnknownError = exports.ConductorInternalError = exports.ConductorConnectionError = exports.ConductorAuthenticationError = exports.ConductorInvalidRequestError = exports.ConductorIntegrationConnectionError = exports.ConductorIntegrationError = exports.ConductorError = exports.DEFAULT_END_USER_MESSAGE = void 0;
|
|
4
4
|
/* eslint-disable max-classes-per-file -- Use one module for all error classes. */
|
|
5
5
|
// Matches server-side default value.
|
|
6
6
|
exports.DEFAULT_END_USER_MESSAGE = "An internal server error occurred. Please try again later.";
|
|
@@ -10,7 +10,7 @@ exports.DEFAULT_END_USER_MESSAGE = "An internal server error occurred. Please tr
|
|
|
10
10
|
*/
|
|
11
11
|
class ConductorError extends Error {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Categorizes the error.
|
|
14
14
|
*
|
|
15
15
|
* This value is the same as the subclass name. E.g.,
|
|
16
16
|
* `"ConductorIntegrationError"` or `"ConductorInvalidRequestError"`.
|
|
@@ -21,7 +21,7 @@ class ConductorError extends Error {
|
|
|
21
21
|
* handling for specific errors. E.g., `"INTEGRATION_CONNECTION_MISSING"`,
|
|
22
22
|
* `"API_KEY_INVALID"`, or `"QBD_REQUEST_ERROR"`.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
24
|
+
* In contrast, `type` is more general and categorizes the error.
|
|
25
25
|
*/
|
|
26
26
|
code;
|
|
27
27
|
/**
|
|
@@ -29,27 +29,27 @@ class ConductorError extends Error {
|
|
|
29
29
|
*/
|
|
30
30
|
message;
|
|
31
31
|
/**
|
|
32
|
-
* The end-user-friendly error message to display in your app's UI
|
|
33
|
-
* end-
|
|
32
|
+
* The end-user-friendly error message to display in your app's UI to your
|
|
33
|
+
* end-users.
|
|
34
34
|
*
|
|
35
|
-
* This value exists for *every* error. E.g.,
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
35
|
+
* This value exists for *every* error. E.g., for a QBD connection error, it
|
|
36
|
+
* might recommend the end-user to check that their QuickBooks Desktop is open
|
|
37
|
+
* and that they're logged in. But if a Conductor API key is expired, e.g.,
|
|
38
|
+
* this message will just say "An internal server error occurred. Please try
|
|
39
|
+
* again later.".
|
|
40
40
|
*/
|
|
41
41
|
endUserMessage;
|
|
42
42
|
/**
|
|
43
43
|
* The unique error code supplied by the third-party integration for errors
|
|
44
|
-
*
|
|
45
|
-
* `
|
|
46
|
-
* for specific errors from the third-party
|
|
44
|
+
* returned by the integration (i.e., `ConductorIntegrationError`) or
|
|
45
|
+
* integration connector (i.e., `ConductorIntegrationConnectorError`). This is
|
|
46
|
+
* useful for adding special handling for specific errors from the third-party
|
|
47
|
+
* integration or connector.
|
|
47
48
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* error message for this code is in `error.message`.
|
|
49
|
+
* The integration's corresponding error message for this code is in
|
|
50
|
+
* `error.message`.
|
|
51
51
|
*
|
|
52
|
-
* The third-party
|
|
52
|
+
* The third-party integrations' error codes are not standardized, so you
|
|
53
53
|
* should not rely on this code to be the same across integrations.
|
|
54
54
|
*/
|
|
55
55
|
integrationCode;
|
|
@@ -85,11 +85,14 @@ class ConductorError extends Error {
|
|
|
85
85
|
exports.ConductorError = ConductorError;
|
|
86
86
|
/**
|
|
87
87
|
* Raised when the third-party integration returned an error while processing
|
|
88
|
-
* your end-user's request.
|
|
89
|
-
*
|
|
88
|
+
* your end-user's request. This is likely due to an issue with your request or
|
|
89
|
+
* data handling that you must fix.
|
|
90
90
|
*
|
|
91
|
-
*
|
|
92
|
-
* integration
|
|
91
|
+
* E.g., a `ListID` you provided was not found in QuickBooks Desktop, or an
|
|
92
|
+
* accounting value you provided failed the integration's accounting rules.
|
|
93
|
+
*
|
|
94
|
+
* See `error.integrationCode` for the error code that the integration returned,
|
|
95
|
+
* if any.
|
|
93
96
|
*/
|
|
94
97
|
class ConductorIntegrationError extends ConductorError {
|
|
95
98
|
static rawType = "INTEGRATION_ERROR";
|
|
@@ -98,6 +101,24 @@ class ConductorIntegrationError extends ConductorError {
|
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
exports.ConductorIntegrationError = ConductorIntegrationError;
|
|
104
|
+
/**
|
|
105
|
+
* Raised when an error occurred connecting to the third-party integration on
|
|
106
|
+
* behalf of the end-user. Most likely, something is wrong with the end-user's
|
|
107
|
+
* integration connection or configuration that the end-user must fix, not you.
|
|
108
|
+
*
|
|
109
|
+
* E.g., QuickBooks Web Connector (QBWC) failed to connect to QuickBooks Desktop
|
|
110
|
+
* on the end-user's computer.
|
|
111
|
+
*
|
|
112
|
+
* See `error.integrationCode` for the error code that the integration connector
|
|
113
|
+
* returned, if any.
|
|
114
|
+
*/
|
|
115
|
+
class ConductorIntegrationConnectionError extends ConductorError {
|
|
116
|
+
static rawType = "INTEGRATION_CONNECTION_ERROR";
|
|
117
|
+
constructor(options) {
|
|
118
|
+
super({ ...options, type: ConductorIntegrationConnectionError.rawType });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.ConductorIntegrationConnectionError = ConductorIntegrationConnectionError;
|
|
101
122
|
/**
|
|
102
123
|
* Raised when you make an API call with the wrong parameters, in the wrong
|
|
103
124
|
* state, or in an invalid way.
|
|
@@ -121,7 +142,7 @@ class ConductorAuthenticationError extends ConductorError {
|
|
|
121
142
|
}
|
|
122
143
|
exports.ConductorAuthenticationError = ConductorAuthenticationError;
|
|
123
144
|
/**
|
|
124
|
-
* Raised when there
|
|
145
|
+
* Raised when there was a network problem between the client (on your server)
|
|
125
146
|
* and Conductor's servers. E.g., a downed network or a bad TLS certificate.
|
|
126
147
|
*/
|
|
127
148
|
class ConductorConnectionError extends ConductorError {
|
|
@@ -132,7 +153,7 @@ class ConductorConnectionError extends ConductorError {
|
|
|
132
153
|
}
|
|
133
154
|
exports.ConductorConnectionError = ConductorConnectionError;
|
|
134
155
|
/**
|
|
135
|
-
* Raised when something
|
|
156
|
+
* Raised when something went wrong on Conductor's end. (These are rare.)
|
|
136
157
|
*/
|
|
137
158
|
class ConductorInternalError extends ConductorError {
|
|
138
159
|
static rawType = "INTERNAL_ERROR";
|
|
@@ -158,6 +179,9 @@ function generateConductorErrorFromType(options) {
|
|
|
158
179
|
case ConductorIntegrationError.rawType: {
|
|
159
180
|
return new ConductorIntegrationError(options);
|
|
160
181
|
}
|
|
182
|
+
case ConductorIntegrationConnectionError.rawType: {
|
|
183
|
+
return new ConductorIntegrationConnectionError(options);
|
|
184
|
+
}
|
|
161
185
|
case ConductorInvalidRequestError.rawType: {
|
|
162
186
|
return new ConductorInvalidRequestError(options);
|
|
163
187
|
}
|
package/package.json
CHANGED