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
| RequestAbortedError | HTTP request was aborted by the client |
245
-
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
246
-
| ConnectionError | HTTP client was unable to make a request to a server |
247
-
| InvalidRequestError | Any input used to create a request is invalid |
248
-
| UnexpectedClientError | Unrecognised or unexpected error |
249
-
250
-
In addition, when custom error responses are specified for an operation, the SDK may throw their associated Error type. You can refer to respective *Errors* tables in SDK docs for more details on possible error types for each operation. For example, the `textToImage` method may throw the following errors:
238
+
Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `textToImage` method may throw the following errors:
If the method throws an error and it is not captured by the known errors, it will default to throwing a `SDKError`.
247
+
258
248
```typescript
259
249
import { Livepeer } from"@livepeer/ai";
260
250
import {
@@ -278,8 +268,9 @@ async function run() {
278
268
console.log(result);
279
269
} catch (err) {
280
270
switch (true) {
271
+
// The server response does not match the expected SDK schema
281
272
case (errinstanceofSDKValidationError): {
282
-
//Validation errors can be pretty-printed
273
+
//Pretty-print will provide a human-readable multi-line error message
283
274
console.error(err.pretty());
284
275
// Raw value may also be inspected
285
276
console.error(err.rawValue);
@@ -296,6 +287,7 @@ async function run() {
296
287
return;
297
288
}
298
289
default: {
290
+
// Other errors such as network errors, see HTTPClientErrors for more details
299
291
throwerr;
300
292
}
301
293
}
@@ -306,7 +298,17 @@ run();
306
298
307
299
```
308
300
309
-
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 string since validation errors can list many issues and the plain error string may be difficult read when debugging.
301
+
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.
302
+
303
+
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:
0 commit comments