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
application/json: {"externalId": "<id>", "name": null, "description": "yet plus utter queasily what juvenile wound", "effectiveDate": "2024-11-10T13:58:54.564Z", "category": "CLOUD_SECURITY"}
303
309
responses:
304
310
"201":
305
311
application/json: {"id": "a2f7e1b9d0c3f4e5a6c7b8d9", "externalId": "CRY-104", "name": "Data encryption utilized", "description": "Access reviews are performed to ensure that access is appropriate for the user's role and responsibilities.", "source": "Vanta", "domains": ["CRYPTOGRAPHIC_PROTECTIONS"], "owner": {"id": "65e1efde08e8478f143a8ff9", "displayName": "Example Owner", "emailAddress": "[email protected]"}, "role": "CONTROLLER", "customFields": [{"label": "Additional context", "value": "This control is critical for GDPR compliance"}]}
// The server response does not match the expected SDK schema
367
-
case (errinstanceofSDKValidationError):
368
-
{
369
-
// Pretty-print will provide a human-readable multi-line error message
370
-
console.error(err.pretty());
371
-
// Raw value may also be inspected
372
-
console.error(err.rawValue);
373
-
return;
374
-
}
375
-
apierror.js;
376
-
// Server returned an error status code or an unknown content type
377
-
case (errinstanceofAPIError): {
378
-
console.error(err.statusCode);
379
-
console.error(err.rawResponse.body);
380
-
return;
381
-
}
382
-
default: {
383
-
// Other errors such as network errors, see HTTPClientErrors for more details
384
-
throwerr;
385
-
}
363
+
} catch (error) {
364
+
if (errorinstanceoferrors.VantaError) {
365
+
console.log(error.message);
366
+
console.log(error.statusCode);
367
+
console.log(error.body);
368
+
console.log(error.headers);
386
369
}
387
370
}
388
371
}
@@ -391,17 +374,26 @@ run();
391
374
392
375
```
393
376
394
-
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.
377
+
### Error Classes
378
+
**Primary error:**
379
+
*[`VantaError`](./src/models/errors/vantaerror.ts): The base class for HTTP error responses.
380
+
381
+
<details><summary>Less common errors (6)</summary>
382
+
383
+
<br />
395
384
396
-
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:
385
+
**Network errors:**
386
+
*[`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
387
+
*[`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
388
+
*[`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
389
+
*[`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
390
+
*[`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.
| RequestAbortedError | HTTP request was aborted by the client |
401
-
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
402
-
| ConnectionError | HTTP client was unable to make a request to a server |
403
-
| InvalidRequestError | Any input used to create a request is invalid |
404
-
| UnexpectedClientError | Unrecognised or unexpected error |
392
+
393
+
**Inherit from [`VantaError`](./src/models/errors/vantaerror.ts)**:
394
+
*[`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.
395
+
396
+
</details>
405
397
<!-- End Error Handling [errors] -->
406
398
407
399
<!-- Start Server Selection [server] -->
@@ -430,7 +422,6 @@ const vanta = new Vanta({
430
422
asyncfunction run() {
431
423
const result =awaitvanta.audits.list({});
432
424
433
-
// Handle the result
434
425
console.log(result);
435
426
}
436
427
@@ -445,14 +436,13 @@ The default server can also be overridden globally by passing a URL to the `serv
0 commit comments