@saulo.martins/api-client 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apiError.js +4 -1
- package/package.json +1 -1
- package/src/apiError.ts +4 -1
package/dist/apiError.js
CHANGED
|
@@ -8,7 +8,10 @@ export function getApiErrorFromResponse(data) {
|
|
|
8
8
|
'code' in msg) {
|
|
9
9
|
return { message: msg.message, code: msg.code };
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
// NestJS standard format: { message: "...", code: "SOME_CODE" } at top level
|
|
12
|
+
const dataObj = data;
|
|
13
|
+
const topCode = typeof dataObj['code'] === 'string' ? dataObj['code'] : undefined;
|
|
14
|
+
return { message: typeof msg === 'string' ? msg : '', code: topCode };
|
|
12
15
|
}
|
|
13
16
|
export function attachCodeToError(err, code) {
|
|
14
17
|
err.code = code;
|
package/package.json
CHANGED
package/src/apiError.ts
CHANGED
|
@@ -18,7 +18,10 @@ export function getApiErrorFromResponse(data: unknown): {
|
|
|
18
18
|
) {
|
|
19
19
|
return { message: msg.message, code: msg.code };
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
// NestJS standard format: { message: "...", code: "SOME_CODE" } at top level
|
|
22
|
+
const dataObj = data as Record<string, unknown>;
|
|
23
|
+
const topCode = typeof dataObj['code'] === 'string' ? dataObj['code'] : undefined;
|
|
24
|
+
return { message: typeof msg === 'string' ? msg : '', code: topCode };
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export function attachCodeToError(
|