@ethisyscore/plugin-ui 1.100.4 → 1.100.5
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.
|
@@ -116,8 +116,9 @@ declare function createPluginPageDefiner(config: PluginPageDefinerConfig): (Page
|
|
|
116
116
|
* `meta.errorTitle` is the title when a call site set one — that is the contract those 1,100 sites
|
|
117
117
|
* were already written against. Otherwise the title is derived from the `[Status]` prefix the
|
|
118
118
|
* SDK's `ResultMapper` puts on every failure, so an unlabelled call still says something truer
|
|
119
|
-
* than "Error".
|
|
120
|
-
*
|
|
119
|
+
* than "Error". BOTH bracketed prefixes are stripped from the description — the status one and the
|
|
120
|
+
* plugin’s own [ERROR_CODE] behind it: they are our wire format, and an operator reading either is
|
|
121
|
+
* reading our plumbing rather than their problem.
|
|
121
122
|
*
|
|
122
123
|
* A page that renders its own error UI opts out with `meta.suppressErrorToast`, matching the host.
|
|
123
124
|
*/
|
|
@@ -116,8 +116,9 @@ declare function createPluginPageDefiner(config: PluginPageDefinerConfig): (Page
|
|
|
116
116
|
* `meta.errorTitle` is the title when a call site set one — that is the contract those 1,100 sites
|
|
117
117
|
* were already written against. Otherwise the title is derived from the `[Status]` prefix the
|
|
118
118
|
* SDK's `ResultMapper` puts on every failure, so an unlabelled call still says something truer
|
|
119
|
-
* than "Error".
|
|
120
|
-
*
|
|
119
|
+
* than "Error". BOTH bracketed prefixes are stripped from the description — the status one and the
|
|
120
|
+
* plugin’s own [ERROR_CODE] behind it: they are our wire format, and an operator reading either is
|
|
121
|
+
* reading our plumbing rather than their problem.
|
|
121
122
|
*
|
|
122
123
|
* A page that renders its own error UI opts out with `meta.suppressErrorToast`, matching the host.
|
|
123
124
|
*/
|
|
@@ -44,14 +44,20 @@ function splitStatusPrefix(message) {
|
|
|
44
44
|
}
|
|
45
45
|
return body.length > 0 ? { status, body } : { status: null, body: message };
|
|
46
46
|
}
|
|
47
|
+
var ErrorCodePrefix = new RegExp(String.raw`^\[[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\]\s*`);
|
|
48
|
+
function stripErrorCodePrefix(body) {
|
|
49
|
+
const stripped = body.replace(ErrorCodePrefix, "");
|
|
50
|
+
return stripped.length > 0 ? stripped : body;
|
|
51
|
+
}
|
|
47
52
|
function surfaceError(error, meta) {
|
|
48
53
|
if (meta?.suppressErrorToast === true) {
|
|
49
54
|
return;
|
|
50
55
|
}
|
|
51
56
|
const raw = error instanceof Error && error.message.length > 0 ? error.message : "An unexpected error occurred";
|
|
52
57
|
const { status, body } = splitStatusPrefix(raw);
|
|
58
|
+
const reason = stripErrorCodePrefix(body);
|
|
53
59
|
const title = meta?.errorTitle ?? (status !== null ? STATUS_TITLES.get(status) ?? GENERIC_TITLE : GENERIC_TITLE);
|
|
54
|
-
showErrorToast(title,
|
|
60
|
+
showErrorToast(title, reason);
|
|
55
61
|
}
|
|
56
62
|
function createPluginQueryClient(config) {
|
|
57
63
|
return new QueryClient({
|