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
@@ -99,41 +100,37 @@ The [project README](https://github.com/SAP/ai-sdk-js/blob/main/sample-code/READ
99
100
A common error scenario is `Request failed with status code STATUS_CODE` coming from `AxiosError`.
100
101
In this case, SAP Cloud SDK for AI uses [`ErrorWithCause`](https://sap.github.io/cloud-sdk/docs/js/features/error-handling) to provide more detailed error information.
101
102
102
-
The following example shows how to access useful information from a nested `ErrorWithCause`.
103
+
### Accessing Error Information
104
+
105
+
For example, for the following nested `ErrorWithCause`
103
106
104
107
```ts
105
-
try {
106
-
...// execute request
107
-
} catch (e) {
108
-
/* Print error messages from different layers */
109
-
// Example: "Error: Failed to fetch the deployments."
110
-
console.error(e.message);
111
-
// Example: "Cause: executeRequest() function failed."
112
-
console.error(e.cause?.message);
113
-
// Example: "Root cause: Request failed with status code 404"
114
-
console.error(e.rootCause?.message);
115
-
116
-
/* Print error response from the server */
117
-
console.error(e.cause?.response?.data);
118
-
/* Print error stack */
119
-
console.error(e.stack);
120
-
}
108
+
const rootCause =newError('The root cause is a bug!');
109
+
const lowerLevelErrorWithCause =newErrorWithCause('Failed to call function foo().', rootCause);
0 commit comments