From e79eee53bc0f3bca3e21c8efb557218a214f1022 Mon Sep 17 00:00:00 2001 From: mdelez <60604010+mdelez@users.noreply.github.com> Date: Thu, 8 Sep 2022 16:33:53 +0200 Subject: [PATCH] fix: rollbar fixes (DEV-1324) (#817) * fix(project): check if project is undefined before accessing properties of project * fix(resource): check if representationsToDisplay is undefined before calling .length on it * fix(rollbar): don't report error to rollbar if currentProjectOntologies isn't found in the cache * fix(results): check if resInfo is undefined before accessing its properties * chore(results): write cleaner code --- .../ontology-class-instance.component.ts | 3 ++- .../ontology/ontology-form/ontology-form.component.ts | 3 ++- src/app/project/ontology/ontology.component.ts | 3 ++- src/app/project/ontology/ontology.service.ts | 3 ++- .../ontology/property-form/property-form.component.ts | 3 ++- .../ontology/property-info/property-info.component.ts | 6 ++++-- .../resource-class-info/resource-class-info.component.ts | 3 ++- src/app/project/project.component.html | 2 +- src/app/workspace/resource/resource.component.html | 4 ++-- src/app/workspace/results/results.component.ts | 2 +- 10 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/app/project/beta/ontology-classes/ontology-class-instance/ontology-class-instance.component.ts b/src/app/project/beta/ontology-classes/ontology-class-instance/ontology-class-instance.component.ts index 342e90d19f..89237c3a12 100644 --- a/src/app/project/beta/ontology-classes/ontology-class-instance/ontology-class-instance.component.ts +++ b/src/app/project/beta/ontology-classes/ontology-class-instance/ontology-class-instance.component.ts @@ -87,7 +87,8 @@ export class OntologyClassInstanceComponent implements OnChanges { // find ontology of current resource class to get the class label const classes = ontologies[ontologies.findIndex(onto => onto.id === this.ontoId)].getAllClassDefinitions(); this.resClass = classes[classes.findIndex(res => res.id === this.classId)]; - } + }, + () => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache ); } diff --git a/src/app/project/ontology/ontology-form/ontology-form.component.ts b/src/app/project/ontology/ontology-form/ontology-form.component.ts index 07ef0e5a20..2f5b542064 100644 --- a/src/app/project/ontology/ontology-form/ontology-form.component.ts +++ b/src/app/project/ontology/ontology-form/ontology-form.component.ts @@ -138,7 +138,8 @@ export class OntologyFormComponent implements OnInit { const name = this._ontologyService.getOntologyName(onto.id); this.existingOntologyNames.push(name); }); - } + }, + () => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache ); } diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts index 0f0c10a4de..3625b9356f 100644 --- a/src/app/project/ontology/ontology.component.ts +++ b/src/app/project/ontology/ontology.component.ts @@ -383,7 +383,8 @@ export class OntologyComponent implements OnInit { // update current list of project ontologies ontologies[ontologies.findIndex(onto => onto.id === ontology.id)] = ontology; this._cache.set('currentProjectOntologies', ontologies); - } + }, + () => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache ); // grab the onto class information to display diff --git a/src/app/project/ontology/ontology.service.ts b/src/app/project/ontology/ontology.service.ts index cd09e069de..9842e5745c 100644 --- a/src/app/project/ontology/ontology.service.ts +++ b/src/app/project/ontology/ontology.service.ts @@ -116,7 +116,8 @@ export class OntologyService { (ontologies: ReadOntology[]) => { const onto = ontologies.find(i => i.id === baseOntoIri); superPropIri = onto.properties[subProp].subPropertyOf[0]; - } + }, + () => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache ); } diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index 472860f263..148721fb9f 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -191,7 +191,8 @@ export class PropertyFormComponent implements OnInit { this.ontologyClasses.push(ontoClasses); } }); - } + }, + () => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache ); // b) in case of list value: diff --git a/src/app/project/ontology/property-info/property-info.component.ts b/src/app/project/ontology/property-info/property-info.component.ts index ce137dd520..97d0f40e3d 100644 --- a/src/app/project/ontology/property-info/property-info.component.ts +++ b/src/app/project/ontology/property-info/property-info.component.ts @@ -214,7 +214,8 @@ export class PropertyInfoComponent implements OnChanges, AfterContentInit { this.propAttribute = onto.classes[this.propDef.objectType].label; this.propAttributeComment = onto.classes[this.propDef.objectType].comment; } - } + }, + () => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache ); } else { this.propAttribute = this.ontology.classes[this.propDef.objectType].label; @@ -256,7 +257,8 @@ export class PropertyInfoComponent implements OnChanges, AfterContentInit { } }); }); - } + }, + () => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache ); } } diff --git a/src/app/project/ontology/resource-class-info/resource-class-info.component.ts b/src/app/project/ontology/resource-class-info/resource-class-info.component.ts index aacd84e222..3636ba4569 100644 --- a/src/app/project/ontology/resource-class-info/resource-class-info.component.ts +++ b/src/app/project/ontology/resource-class-info/resource-class-info.component.ts @@ -124,7 +124,8 @@ export class ResourceClassInfoComponent implements OnInit { }; this.ontoProperties.push(prepareList); }); - } + }, + () => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache ); // get currently selected ontology diff --git a/src/app/project/project.component.html b/src/app/project/project.component.html index 2569ba63e2..5b578b2035 100644 --- a/src/app/project/project.component.html +++ b/src/app/project/project.component.html @@ -18,7 +18,7 @@ -