Skip to content
Snippets Groups Projects
Commit a76f2cf8 authored by rhenck's avatar rhenck
Browse files

[editor] Add error handling of empty or invalid unit definitions

Now shows an error message and continues with an empty unit.
parent 88c138e7
No related branches found
No related tags found
No related merge requests found
...@@ -48,9 +48,20 @@ export class UnitService { ...@@ -48,9 +48,20 @@ export class UnitService {
} }
loadUnitDefinition(unitDefinition: string): void { loadUnitDefinition(unitDefinition: string): void {
if (unitDefinition) { this.idService.reset();
this.idService.reset(); let error = false;
this.unit = new Unit(JSON.parse(unitDefinition)); 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({});
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment