diff --git a/packages/compas-open-scd/src/compas-services/foundation.ts b/packages/compas-open-scd/src/compas-services/foundation.ts index b0321bf3a..2231a4ed3 100644 --- a/packages/compas-open-scd/src/compas-services/foundation.ts +++ b/packages/compas-open-scd/src/compas-services/foundation.ts @@ -103,6 +103,20 @@ export function createLogEvent(element: Element, reason: any): void { } } +export function createNSDocLogEvent(element: Element, fileName: string): void { + if (element) { + element.dispatchEvent( + newLogEvent({ + kind: 'warning', + title: get('compas.warning.nsdoc'), + message: get('compas.warning.nsdocDetails', { + fileName: fileName, + }), + }) + ); + } +} + export function getWebsocketUri(settingsUrl: string): string { if (settingsUrl.startsWith('http://') || settingsUrl.startsWith('https://')) { return settingsUrl diff --git a/packages/compas-open-scd/src/compas/CompasNsdoc.ts b/packages/compas-open-scd/src/compas/CompasNsdoc.ts index f363f359a..8d2111b7f 100644 --- a/packages/compas-open-scd/src/compas/CompasNsdoc.ts +++ b/packages/compas-open-scd/src/compas/CompasNsdoc.ts @@ -1,6 +1,9 @@ import { newLoadNsdocEvent } from '../Setting.js'; -import { createLogEvent } from '../compas-services/foundation.js'; +import { + createLogEvent, + createNSDocLogEvent, +} from '../compas-services/foundation.js'; import { CompasSclValidatorService } from '../compas-services/CompasValidatorService.js'; import { CompasNSDocFileService } from '../compas-services/CompasNSDocFileService.js'; @@ -39,8 +42,8 @@ async function processNsdocFile( component.dispatchEvent(newLoadNsdocEvent(nsdocContent, filename)); localStorage.setItem(checksumKey, checksum); }) - .catch(reason => { - createLogEvent(component, reason); + .catch(() => { + createNSDocLogEvent(component, filename); }); } else { console.debug(`Loading NSDoc File '${nsdocId}' skipped, already loaded.`); diff --git a/packages/compas-open-scd/src/translations/de.ts b/packages/compas-open-scd/src/translations/de.ts index 154eaa9cc..1d4d873e4 100644 --- a/packages/compas-open-scd/src/translations/de.ts +++ b/packages/compas-open-scd/src/translations/de.ts @@ -878,6 +878,10 @@ export const de: Translations = { server: '???', serverDetails: '{{type}}: {{message}}', }, + warning: { + nsdoc: 'Fehler beim Laden des NSD-Prozesses', + nsdocDetails: 'Datei kann nicht geladen werden: {{fileName}}', + }, changeset: { major: '???', minor: '???', diff --git a/packages/compas-open-scd/src/translations/en.ts b/packages/compas-open-scd/src/translations/en.ts index fde0fbd7f..a9ab1ec9d 100644 --- a/packages/compas-open-scd/src/translations/en.ts +++ b/packages/compas-open-scd/src/translations/en.ts @@ -871,6 +871,10 @@ export const en = { server: 'Error communicating with CoMPAS Ecosystem', serverDetails: '{{type}}: {{message}}', }, + warning: { + nsdoc: 'Process NSD loading error', + nsdocDetails: 'Cannot load file: {{fileName}}', + }, changeset: { major: 'Major change', minor: 'Minor change',