Skip to content

Commit 9f19ef5

Browse files
authored
Add kuzzleStack property to KuzzleError (#620)
## What does this PR do? Add the `kuzzleStack` property containing the original stacktrace from Kuzzle. It will allow to display only the Kuzzle stacktrace when an error occurs (e.g. in Kourou the user does not care about the SDK stacktrace)
1 parent f1fb225 commit 9f19ef5

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

doc/7/core-classes/kuzzle-error/properties/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ order: 10
99

1010
# Properties
1111

12-
| Property name | Type | Description |
13-
| -------------------- | -------- | --------------------------------------- |
14-
| `message` | <pre>string</pre> | Error message |
15-
| `status` | <pre>number</pre> | Error status code |
16-
| `stack` | <pre>string</pre> | Error stacktrace (only in development mode) |
17-
| `id` | <pre>string</pre> | Error unique identifier |
18-
| `code` | <pre>string</pre> | Error unique code |
12+
| Property name | Type | Description |
13+
|---------------|-------------------|---------------------------------------------------------------------|
14+
| `kuzzleStack` | <pre>string</pre> | Kuzzle stacktrace (only in development mode) |
15+
| `message` | <pre>string</pre> | Error message |
16+
| `status` | <pre>number</pre> | Error status code |
17+
| `stack` | <pre>string</pre> | Complete error stacktrace (Kuzzle + SDK) (only in development mode) |
18+
| `id` | <pre>string</pre> | Error unique identifier |
19+
| `code` | <pre>string</pre> | Error unique code |
1920

doc/7/essentials/error-handling/index.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ All SDK methods return a promise, that can be rejected with a `KuzzleError` valu
1212

1313
[KuzzleError](/sdk/js/7/core-classes/kuzzle-error/introduction) objects inherit the standard `Error` object, and add the following properties to it:
1414

15-
| Property | Type | Description |
16-
| -------- | ----------------- | ------------------------------------------------------------------------------------------ |
17-
| `status` | <pre>number</pre> | Status following [HTTP Standards](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) |
18-
| `stack` | <pre>string</pre> | Error stacktrace (Only in development mode) | `id` | <pre>string</pre> | Error unique identifier |
19-
| `code` | <pre>string</pre> | Error unique code |
15+
| Property | Type | Description |
16+
|---------------|-------------------|----------------------------------------------|
17+
| `kuzzleStack` | <pre>string</pre> | Kuzzle stacktrace (only in development mode) |
18+
| `status` | <pre>number</pre> | Error status code |
19+
| `id` | <pre>string</pre> | Error unique identifier |
20+
| `code` | <pre>string</pre> | Error unique code |
21+
2022

2123

2224
You can find a detailed list of possible errors messages and statuses in the [documentation API](/core/2/api/errors/types).

src/KuzzleError.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class KuzzleError extends Error {
7777
// If we have a stacktrace coming from Kuzzle, merge it with
7878
// the SDK one
7979
if (apiError.stack) {
80+
this.kuzzleStack = apiError.stack;
8081
this.stack = apiError.stack + '\n';
8182
this.stack += ' |\n';
8283
this.stack += ' |\n';

0 commit comments

Comments
 (0)