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 |
765
-
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
766
-
| ConnectionError | HTTP client was unable to make a request to a server |
767
-
| InvalidRequestError | Any input used to create a request is invalid |
768
-
| UnexpectedClientError | Unrecognised or unexpected error |
769
-
770
-
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 `list` method may throw the following errors:
770
+
Some methods specify known errors which can be thrown. All the known errors are enumerated in the `sdk/models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `list` 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`.
778
+
777
779
```typescript
778
780
import { CodatLending } from"@codat/lending";
779
781
import {
@@ -793,14 +795,16 @@ async function run() {
793
795
pageSize: 100,
794
796
query: "id=e3334455-1aed-4e71-ab43-6bccf12092ee",
795
797
orderBy: "-modifiedDate",
798
+
tags: "region=uk && team=invoice-finance",
796
799
});
797
800
798
801
// Handle the result
799
802
console.log(result);
800
803
} catch (err) {
801
804
switch (true) {
805
+
// The server response does not match the expected SDK schema
802
806
case (errinstanceofSDKValidationError): {
803
-
//Validation errors can be pretty-printed
807
+
//Pretty-print will provide a human-readable multi-line error message
804
808
console.error(err.pretty());
805
809
// Raw value may also be inspected
806
810
console.error(err.rawValue);
@@ -812,6 +816,7 @@ async function run() {
812
816
return;
813
817
}
814
818
default: {
819
+
// Other errors such as network errors, see HTTPClientErrors for more details
815
820
throwerr;
816
821
}
817
822
}
@@ -822,7 +827,17 @@ run();
822
827
823
828
```
824
829
825
-
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.
830
+
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.
831
+
832
+
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 `sdk/models/errors/httpclienterrors.ts` module:
0 commit comments