@futdevpro/fsm-dynamo 1.20.86 → 1.20.88
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/build/_collections/utils/extract-error-message.util.d.ts +29 -16
- package/build/_collections/utils/extract-error-message.util.d.ts.map +1 -1
- package/build/_collections/utils/extract-error-message.util.js +28 -24
- package/build/_collections/utils/extract-error-message.util.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,6 +22,21 @@ export interface DyFM_ExtractErrorMessage_Options {
|
|
|
22
22
|
* chain, the component / API-service log). Opt in for diagnostic surfaces.
|
|
23
23
|
*/
|
|
24
24
|
includeHttpStatus?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* When `true` and no message field exists, the result is `'Malformed error: <JSON of the payload>'`. Default:
|
|
27
|
+
* `false` — the raw payload is technical (and may carry the status); the user gets `fallback`. The raw error stays
|
|
28
|
+
* with the caller (the form-error panel's copy chain, `DyFM_reportMalformedError`). Opt in for diagnostic surfaces.
|
|
29
|
+
*/
|
|
30
|
+
includeRawPayload?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* When `true`, the TECHNICAL message fields are consulted too, after the user-facing ones: `_message` (the DyFM debug
|
|
33
|
+
* message) and `message` (e.g. `HttpErrorResponse.message` = "Http failure response for …"). Default: `false` — the
|
|
34
|
+
* user sees only a user-message field or `fallback`. Measured 2026-09-24: `_message` showed users
|
|
35
|
+
* `DyNX_ApiService call "loginUser" ERROR: Http failure response for …: 404`, and the outer `message` hid the server's
|
|
36
|
+
* `error.__userMessage`; across the fleet NO caller relied on `message` / `_message` as an intended user text.
|
|
37
|
+
* Opt in for diagnostic surfaces.
|
|
38
|
+
*/
|
|
39
|
+
includeTechnicalMessage?: boolean;
|
|
25
40
|
}
|
|
26
41
|
/**
|
|
27
42
|
* Universal error → human-readable string extractor. **Never** returns the
|
|
@@ -30,21 +45,18 @@ export interface DyFM_ExtractErrorMessage_Options {
|
|
|
30
45
|
* common Angular HttpErrorResponse + plain Error shapes, falling back to a
|
|
31
46
|
* meaningful diagnostic string when the input is malformed.
|
|
32
47
|
*
|
|
33
|
-
* Order of attempts (first non-empty wins):
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* 10. JSON-stringified payload (circular-safe; first 200 chars) as a last
|
|
46
|
-
* resort, prefixed with 'Malformed error: '
|
|
47
|
-
* 11. `options.fallback` (or its default)
|
|
48
|
+
* Order of attempts (first non-empty wins) — USER-FACING fields only by default:
|
|
49
|
+
* 0. If `err` itself is a string, use as-is (the caller meant it as the text)
|
|
50
|
+
* 1. `err.__userMessage` (DyFM_Error user message)
|
|
51
|
+
* 2. `err.userMessage` (deprecated DyFM_Error_Settings field, still seen on some payloads)
|
|
52
|
+
* 3. `err.error.__userMessage` (HttpErrorResponse wrapping a DyFM_Error in its body — beats the outer technical
|
|
53
|
+
* `message`)
|
|
54
|
+
* 4. `err.error.userMessage`
|
|
55
|
+
* 5. ONLY with `includeTechnicalMessage: true`: `err._message` · `err.message` · `err.error._message` ·
|
|
56
|
+
* `err.error.message` (debug / transport texts — never a user message by default)
|
|
57
|
+
* 6. ONLY with `includeRawPayload: true`: the JSON-stringified payload (circular-safe; first 200 chars),
|
|
58
|
+
* prefixed with 'Malformed error: ' (default: skipped — raw JSON is not a user message)
|
|
59
|
+
* 7. `options.fallback` (or its default)
|
|
48
60
|
*
|
|
49
61
|
* Only when `includeHttpStatus: true` (opt-in, default `false`) and the input
|
|
50
62
|
* looks like a HttpErrorResponse, the status + statusText are appended in
|
|
@@ -68,7 +80,8 @@ export declare function DyFM_extractErrorMessage(err: DyFM_AnyError | unknown, o
|
|
|
68
80
|
* Convenience: same as DyFM_extractErrorMessage but always includes a default
|
|
69
81
|
* prefix derived from the calling context, useful for adding diagnostic
|
|
70
82
|
* breadcrumbs without per-call boilerplate. Diagnostic ⇒ it keeps the HTTP
|
|
71
|
-
* status
|
|
83
|
+
* status, the technical message and the raw payload (`includeHttpStatus` + `includeTechnicalMessage` +
|
|
84
|
+
* `includeRawPayload`) — do not show its result to users.
|
|
72
85
|
*/
|
|
73
86
|
export declare function DyFM_formatError(err: DyFM_AnyError | unknown, prefix: string): string;
|
|
74
87
|
export declare function DyFM_registerMalformedErrorSink(fn: (err: unknown, context?: string) => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-error-message.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/extract-error-message.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAc,MAAM,kDAAkD,CAAC;AAG7F;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"extract-error-message.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/extract-error-message.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAc,MAAM,kDAAkD,CAAC;AAG7F;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,aAAa,GAAG,OAAO,EAC5B,OAAO,CAAC,EAAE,gCAAgC,GACzC,MAAM,CA+DR;AAqCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,aAAa,GAAG,OAAO,EAC5B,MAAM,EAAE,MAAM,GACb,MAAM,CAIR;AAiBD,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,GAC3C,IAAI,CAEN;AAED,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,OAAO,EACZ,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAmBN"}
|
|
@@ -11,21 +11,18 @@ exports.DyFM_reportMalformedError = DyFM_reportMalformedError;
|
|
|
11
11
|
* common Angular HttpErrorResponse + plain Error shapes, falling back to a
|
|
12
12
|
* meaningful diagnostic string when the input is malformed.
|
|
13
13
|
*
|
|
14
|
-
* Order of attempts (first non-empty wins):
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* 10. JSON-stringified payload (circular-safe; first 200 chars) as a last
|
|
27
|
-
* resort, prefixed with 'Malformed error: '
|
|
28
|
-
* 11. `options.fallback` (or its default)
|
|
14
|
+
* Order of attempts (first non-empty wins) — USER-FACING fields only by default:
|
|
15
|
+
* 0. If `err` itself is a string, use as-is (the caller meant it as the text)
|
|
16
|
+
* 1. `err.__userMessage` (DyFM_Error user message)
|
|
17
|
+
* 2. `err.userMessage` (deprecated DyFM_Error_Settings field, still seen on some payloads)
|
|
18
|
+
* 3. `err.error.__userMessage` (HttpErrorResponse wrapping a DyFM_Error in its body — beats the outer technical
|
|
19
|
+
* `message`)
|
|
20
|
+
* 4. `err.error.userMessage`
|
|
21
|
+
* 5. ONLY with `includeTechnicalMessage: true`: `err._message` · `err.message` · `err.error._message` ·
|
|
22
|
+
* `err.error.message` (debug / transport texts — never a user message by default)
|
|
23
|
+
* 6. ONLY with `includeRawPayload: true`: the JSON-stringified payload (circular-safe; first 200 chars),
|
|
24
|
+
* prefixed with 'Malformed error: ' (default: skipped — raw JSON is not a user message)
|
|
25
|
+
* 7. `options.fallback` (or its default)
|
|
29
26
|
*
|
|
30
27
|
* Only when `includeHttpStatus: true` (opt-in, default `false`) and the input
|
|
31
28
|
* looks like a HttpErrorResponse, the status + statusText are appended in
|
|
@@ -61,14 +58,18 @@ function DyFM_extractErrorMessage(err, options) {
|
|
|
61
58
|
// properties without forcing each branch into a separate type guard.
|
|
62
59
|
const e = err;
|
|
63
60
|
const innerError = e?.error;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
?? _nonEmptyString(e?.message)
|
|
61
|
+
// user-facing fields first (outer, then the body of a wrapping HttpErrorResponse)
|
|
62
|
+
const userCandidate = _nonEmptyString(e?.__userMessage)
|
|
67
63
|
?? _nonEmptyString(e?.userMessage)
|
|
68
64
|
?? _nonEmptyString(innerError?.__userMessage)
|
|
69
|
-
?? _nonEmptyString(innerError?._message)
|
|
70
|
-
?? _nonEmptyString(innerError?.message)
|
|
71
65
|
?? _nonEmptyString(innerError?.userMessage);
|
|
66
|
+
// technical fields (debug / transport) only on opt-in — see `includeTechnicalMessage`
|
|
67
|
+
const candidate = userCandidate ?? (options?.includeTechnicalMessage === true
|
|
68
|
+
? _nonEmptyString(e?._message)
|
|
69
|
+
?? _nonEmptyString(e?.message)
|
|
70
|
+
?? _nonEmptyString(innerError?._message)
|
|
71
|
+
?? _nonEmptyString(innerError?.message)
|
|
72
|
+
: undefined);
|
|
72
73
|
// HTTP status suffix (always-on by default)
|
|
73
74
|
const status = e?.___status
|
|
74
75
|
?? e?.status
|
|
@@ -82,8 +83,8 @@ function DyFM_extractErrorMessage(err, options) {
|
|
|
82
83
|
if (candidate !== undefined) {
|
|
83
84
|
return `${prefix}${candidate}${httpSuffix}`;
|
|
84
85
|
}
|
|
85
|
-
// No usable text field.
|
|
86
|
-
const jsonAttempt = _safeJsonStringify(err);
|
|
86
|
+
// No usable text field. The raw payload only on opt-in (diagnostic) — the user gets the fallback.
|
|
87
|
+
const jsonAttempt = options?.includeRawPayload === true ? _safeJsonStringify(err) : undefined;
|
|
87
88
|
if (jsonAttempt !== undefined && jsonAttempt !== '{}' && jsonAttempt !== '[]') {
|
|
88
89
|
const trimmed = jsonAttempt.length > 200
|
|
89
90
|
? jsonAttempt.slice(0, 200) + '…'
|
|
@@ -141,10 +142,13 @@ function _safeJsonStringify(v) {
|
|
|
141
142
|
* Convenience: same as DyFM_extractErrorMessage but always includes a default
|
|
142
143
|
* prefix derived from the calling context, useful for adding diagnostic
|
|
143
144
|
* breadcrumbs without per-call boilerplate. Diagnostic ⇒ it keeps the HTTP
|
|
144
|
-
* status
|
|
145
|
+
* status, the technical message and the raw payload (`includeHttpStatus` + `includeTechnicalMessage` +
|
|
146
|
+
* `includeRawPayload`) — do not show its result to users.
|
|
145
147
|
*/
|
|
146
148
|
function DyFM_formatError(err, prefix) {
|
|
147
|
-
return DyFM_extractErrorMessage(err, {
|
|
149
|
+
return DyFM_extractErrorMessage(err, {
|
|
150
|
+
prefix: prefix, includeHttpStatus: true, includeTechnicalMessage: true, includeRawPayload: true,
|
|
151
|
+
});
|
|
148
152
|
}
|
|
149
153
|
/**
|
|
150
154
|
* Reports a raw error payload via the universal client-error capture system
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-error-message.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/extract-error-message.util.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"extract-error-message.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/extract-error-message.util.ts"],"names":[],"mappings":";;AAqFA,4DAkEC;AA4CD,4CAOC;AAiBD,0EAIC;AAED,8DAsBC;AAvMD;;;;;;;;;;;;;;;;;;;;;;;;;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AE,IAAI,EAAE,iBAAiB,EAAE,IAAI;KAChG,CAAC,CAAC;AACL,CAAC;AAGD;;;;;;;;;;;GAWG;AACH,IAAI,mBAA2E,CAAC;AAEhF,SAAgB,+BAA+B,CAC7C,EAA4C;IAE5C,mBAAmB,GAAG,EAAE,CAAC;AAC3B,CAAC;AAED,SAAgB,yBAAyB,CACvC,GAAY,EACZ,OAAgB;IAEhB,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAClC,OAAO;QACT,CAAC;QAAC,MAAM,CAAC;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC;IACD,8EAA8E;IAC9E,IAAI,CAAC;QACH,8EAA8E;QAC9E,MAAM,EAAE,QAAQ,EAAE,GAChB,OAAO,CAAC,YAAY,CAAC,CAAC;QACxB,QAAQ,CAAC,KAAK,CAAC,+BAA+B,OAAO,IAAI,iBAAiB,EAAE,EAAE,GAAG,CAAC,CAAC;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;QACvE,aAAa;IACf,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/fsm-dynamo",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.88",
|
|
4
4
|
"description": "Full Stack Model Collection for Dynamic (NodeJS-Typescript) Framework called Dynamo, by Future Development Ltd.",
|
|
5
5
|
"DyBu_settings": {
|
|
6
6
|
"packageType": "full-stack-package",
|