From b854dcf0c7242560bbb87d50f3ef6ea6e12e5df1 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Thu, 10 Apr 2025 14:59:11 +0300 Subject: [PATCH] UI: Refactoring error msg --- .../components/widget/lib/scada/scada-symbol.models.ts | 2 +- .../home/pages/scada-symbol/scada-symbol.component.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts index e52c6f9f54..abe570fa3c 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts @@ -271,7 +271,7 @@ export const updateScadaSymbolMetadataInContent = (svgContent: string, metadata: const svgDoc = new DOMParser().parseFromString(svgContent, 'image/svg+xml'); const parsererror = svgDoc.getElementsByTagName('parsererror'); if (parsererror?.length) { - return parsererror[0].outerHTML; + throw Error(parsererror[0].textContent) } updateScadaSymbolMetadataInDom(svgDoc, metadata); return svgDoc.documentElement.outerHTML; diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.ts b/ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.ts index caaf0edc01..c618380565 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.ts +++ b/ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.ts @@ -214,10 +214,8 @@ export class ScadaSymbolComponent extends PageComponent this.editObjectCallbacks.tagsUpdated(tags); } const metadata: ScadaSymbolMetadata = this.scadaSymbolFormGroup.get('metadata').value; - const scadaSymbolContent = this.prepareScadaSymbolContent(metadata); - if (scadaSymbolContent.includes('parsererror')) { - this.store.dispatch(new ActionNotificationShow({ message: scadaSymbolContent, type: 'error' })); - } else { + try { + const scadaSymbolContent = this.prepareScadaSymbolContent(metadata); const file = createFileFromContent(scadaSymbolContent, this.symbolData.imageResource.fileName, this.symbolData.imageResource.descriptor.mediaType); const type = imageResourceType(this.symbolData.imageResource); @@ -243,6 +241,8 @@ export class ScadaSymbolComponent extends PageComponent this.init(data); this.updateBreadcrumbs.emit(); }); + } catch (e) { + this.store.dispatch(new ActionNotificationShow({ message: e.message, type: 'error' })); } } }