You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The server response does not match the expected SDK schema
386
-
case (errinstanceofSDKValidationError):
387
-
{
388
-
// Pretty-print will provide a human-readable multi-line error message
389
-
console.error(err.pretty());
390
-
// Raw value may also be inspected
391
-
console.error(err.rawValue);
392
-
return;
393
-
}
394
-
apierror.js;
395
-
// Server returned an error status code or an unknown content type
396
-
case (errinstanceofAPIError): {
397
-
console.error(err.statusCode);
398
-
console.error(err.rawResponse.body);
399
-
return;
400
-
}
401
-
default: {
402
-
// Other errors such as network errors, see HTTPClientErrors for more details
403
-
throwerr;
404
-
}
382
+
} catch (error) {
383
+
if (errorinstanceoferrors.HubspotError) {
384
+
console.log(error.message);
385
+
console.log(error.statusCode);
386
+
console.log(error.body);
387
+
console.log(error.headers);
405
388
}
406
389
}
407
390
}
@@ -410,17 +393,26 @@ run();
410
393
411
394
```
412
395
413
-
Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
396
+
### Error Classes
397
+
**Primary error:**
398
+
*[`HubspotError`](./src/models/errors/hubspoterror.ts): The base class for HTTP error responses.
399
+
400
+
<details><summary>Less common errors (6)</summary>
401
+
402
+
<br />
414
403
415
-
In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module:
404
+
**Network errors:**
405
+
*[`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
406
+
*[`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
407
+
*[`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
408
+
*[`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
409
+
*[`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.
| RequestAbortedError | HTTP request was aborted by the client |
420
-
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
421
-
| ConnectionError | HTTP client was unable to make a request to a server |
422
-
| InvalidRequestError | Any input used to create a request is invalid |
423
-
| UnexpectedClientError | Unrecognised or unexpected error |
411
+
412
+
**Inherit from [`HubspotError`](./src/models/errors/hubspoterror.ts)**:
413
+
*[`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.
414
+
415
+
</details>
424
416
<!-- End Error Handling [errors] -->
425
417
426
418
<!-- Start Server Selection [server] -->
@@ -439,10 +431,9 @@ const hubspot = new Hubspot({
0 commit comments