diff --git a/projects/editor/src/app/services/unit.service.ts b/projects/editor/src/app/services/unit.service.ts index 972a5a797eedfaa4f998fb5f2f0b49023d5a9956..7dbd936f8015a95d0b77c25160205d0dcfbde97d 100644 --- a/projects/editor/src/app/services/unit.service.ts +++ b/projects/editor/src/app/services/unit.service.ts @@ -48,9 +48,20 @@ export class UnitService { } loadUnitDefinition(unitDefinition: string): void { - if (unitDefinition) { - this.idService.reset(); - this.unit = new Unit(JSON.parse(unitDefinition)); + this.idService.reset(); + let error = false; + if (!unitDefinition) { + error = true; + } else { + try { + this.unit = new Unit(JSON.parse(unitDefinition)); + } catch (e) { + error = true; + } + } + if (error) { + this.messageService.showError('Unit konnte nicht geladen werden!'); + this.unit = new Unit({}); } }