This is an automated email from the ASF dual-hosted git repository.
Kusuma04-dev pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new f6cc86c2181 [incubator-kie-tools#4052] Scesim Editor: Error message is
not displayed while opening broken scesim file (#4053)
f6cc86c2181 is described below
commit f6cc86c21816719a27049f4eb3da4bcdd3e0bf5a
Author: Kusuma04-dev <[email protected]>
AuthorDate: Fri Oct 30 15:57:16 2026 +0530
[incubator-kie-tools#4052] Scesim Editor: Error message is not displayed
while opening broken scesim file (#4053)
Co-authored-by: Kusuma <[email protected]>
---
.../src/TestScenarioEditorRoot.tsx | 73 +++++++++++++++++-----
.../src/i18n/ScesimEditorEnvelopeI18n.ts | 2 +
.../scesim-editor-envelope/src/i18n/locales/en.ts | 2 +
3 files changed, 63 insertions(+), 14 deletions(-)
diff --git a/packages/scesim-editor-envelope/src/TestScenarioEditorRoot.tsx
b/packages/scesim-editor-envelope/src/TestScenarioEditorRoot.tsx
index 0ce9dabe818..ba38946c11e 100644
--- a/packages/scesim-editor-envelope/src/TestScenarioEditorRoot.tsx
+++ b/packages/scesim-editor-envelope/src/TestScenarioEditorRoot.tsx
@@ -33,6 +33,13 @@ import { getMarshaller as getDmnMarshaller } from
"@kie-tools/dmn-marshaller";
import * as TestScenarioEditor from
"@kie-tools/scesim-editor/dist/TestScenarioEditor";
import { getMarshaller, SceSimMarshaller, SceSimModel } from
"@kie-tools/scesim-marshaller";
import { EMPTY_ONE_EIGHT } from
"@kie-tools/scesim-editor/dist/resources/EmptyScesimFile";
+import {
+ EmptyState,
+ EmptyStateBody,
+ EmptyStateHeader,
+ EmptyStateIcon,
+} from "@patternfly/react-core/dist/js/components/EmptyState";
+import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex";
import { ScesimEditorEnvelopeI18n } from "./i18n";
export const DMN_MODELS_SEARCH_GLOB_PATTERN = "**/*.dmn";
@@ -52,6 +59,7 @@ export type TestScenarioEditorRootProps = {
};
export type TestScenarioEditorRootState = {
+ error: Error | undefined;
externalModelsByNamespace: TestScenarioEditor.ExternalDmnsIndex;
externalModelsManagerDoneBootstraping: boolean;
isReadOnly: boolean;
@@ -73,6 +81,7 @@ export class TestScenarioEditorRoot extends
React.Component<TestScenarioEditorRo
props.exposing(this);
this.testScenarioEditorRef = React.createRef();
this.state = {
+ error: undefined,
externalModelsByNamespace: new Map(),
externalModelsManagerDoneBootstraping: false,
isReadOnly: props.isReadOnly,
@@ -113,8 +122,7 @@ export class TestScenarioEditorRoot extends
React.Component<TestScenarioEditorRo
openFileNormalizedPosixPathRelativeToTheWorkspaceRoot: string,
content: string
): Promise<void> {
- const marshaller = getMarshaller(content || EMPTY_ONE_EIGHT);
- const scesimModel = marshaller.parser.parse();
+ const { marshaller, scesimModel } = this.getMarshallerAndModel(content);
// Save stack
let savedStackPointer: SceSimModel[] = [];
@@ -123,26 +131,17 @@ export class TestScenarioEditorRoot extends
React.Component<TestScenarioEditorRo
this.setState((prev) => {
savedStackPointer = [...prev.stack];
return {
+ error: undefined,
stack: [scesimModel],
openFileNormalizedPosixPathRelativeToTheWorkspaceRoot,
pointer: 0,
};
});
- if (
- !scesimModel ||
- !scesimModel.ScenarioSimulationModel ||
- scesimModel.ScenarioSimulationModel["parsererror" as keyof typeof
scesimModel.ScenarioSimulationModel]
- ) {
- throw new Error(
- "Impossible to correctly parse the provided SCESIM file. Most likely,
the XML structure of the file is invalid."
- );
- }
-
// Wait the external manager models to load.
await this.externalModelsManagerDoneBootstraping.promise;
- // Set the valeus to render the Test Scenario Editor.
+ // Set the values to render the Test Scenario Editor.
this.setState((prev) => {
// External change to the same file.
if (
@@ -178,6 +177,33 @@ export class TestScenarioEditorRoot extends
React.Component<TestScenarioEditorRo
return this.state.stack[this.state.pointer];
}
+ // Internal methods
+
+ private getMarshallerAndModel(content: string) {
+ try {
+ const marshaller = getMarshaller(content || EMPTY_ONE_EIGHT);
+ const scesimModel = marshaller.parser.parse();
+
+ if (
+ !scesimModel ||
+ !scesimModel.ScenarioSimulationModel ||
+ scesimModel.ScenarioSimulationModel["parsererror" as keyof typeof
scesimModel.ScenarioSimulationModel]
+ ) {
+ throw new Error(
+ "Impossible to correctly parse the provided SCESIM file. Most
likely, the XML structure of the file is invalid."
+ );
+ }
+
+ return { marshaller, scesimModel };
+ } catch (e) {
+ this.setState((s) => ({
+ ...s,
+ error: e instanceof Error ? e : new Error(String(e)),
+ }));
+ throw e;
+ }
+ }
+
private setExternalModelsByNamespace = (externalModelsByNamespace:
TestScenarioEditor.ExternalDmnsIndex) => {
this.setState((prev) => ({ ...prev, externalModelsByNamespace }));
};
@@ -305,7 +331,8 @@ export class TestScenarioEditorRoot extends
React.Component<TestScenarioEditorRo
public render() {
return (
<>
- {this.model && (
+ {this.state.error && <ScesimFallbackError error={this.state.error}
i18n={this.props.i18n} />}
+ {!this.state.error && this.model && (
<>
<TestScenarioEditor.TestScenarioEditor
ref={this.testScenarioEditorRef}
@@ -342,6 +369,24 @@ export class TestScenarioEditorRoot extends
React.Component<TestScenarioEditorRo
}
}
+function ScesimFallbackError({ error, i18n }: { error: Error; i18n:
ScesimEditorEnvelopeI18n }) {
+ return (
+ <Flex justifyContent={{ default: "justifyContentCenter" }} style={{
marginTop: "100px" }}>
+ <EmptyState style={{ maxWidth: "1280px" }}>
+ <EmptyStateHeader
+ titleText={i18n.unableToOpenFile}
+ icon={<EmptyStateIcon icon={() => <div style={{ fontSize: "3em"
}}>😕</div>} />}
+ headingLevel={"h4"}
+ />
+ <br />
+ <EmptyStateBody>
+ {i18n.errorMessage} {error.message}
+ </EmptyStateBody>
+ </EmptyState>
+ </Flex>
+ );
+}
+
function ExternalModelsManager({
workspaceRootAbsolutePosixPath,
thisScesimNormalizedPosixPathRelativeToTheWorkspaceRoot,
diff --git
a/packages/scesim-editor-envelope/src/i18n/ScesimEditorEnvelopeI18n.ts
b/packages/scesim-editor-envelope/src/i18n/ScesimEditorEnvelopeI18n.ts
index 6769d902eb8..4d0bb586575 100644
--- a/packages/scesim-editor-envelope/src/i18n/ScesimEditorEnvelopeI18n.ts
+++ b/packages/scesim-editor-envelope/src/i18n/ScesimEditorEnvelopeI18n.ts
@@ -25,6 +25,8 @@ interface ScesimEditorEnvelopeDictionary extends
ReferenceDictionary<{
i: string;
misc: string;
openCloseDockPanel: string;
+ unableToOpenFile: string;
+ errorMessage: string;
}> {}
export interface ScesimEditorEnvelopeI18n extends
ScesimEditorEnvelopeDictionary, CommonI18n {}
diff --git a/packages/scesim-editor-envelope/src/i18n/locales/en.ts
b/packages/scesim-editor-envelope/src/i18n/locales/en.ts
index 785a65d2c5f..d63391b808c 100644
--- a/packages/scesim-editor-envelope/src/i18n/locales/en.ts
+++ b/packages/scesim-editor-envelope/src/i18n/locales/en.ts
@@ -26,4 +26,6 @@ export const en: ScesimEditorEnvelopeI18n = {
i: "I",
misc: "Misc",
openCloseDockPanel: "Open/Close dock panel",
+ unableToOpenFile: "Unable to open file.",
+ errorMessage: "Error details:",
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]