From 1e6dbb9e1bafbf7d633650455c470e82d1089ec4 Mon Sep 17 00:00:00 2001 From: Adam Midlik Date: Thu, 21 Nov 2024 16:10:05 +0000 Subject: [PATCH] Do not crash on Domain annotations 404 --- src/app/domain-annotations/prop.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/domain-annotations/prop.ts b/src/app/domain-annotations/prop.ts index 0dd77d7..2fc9a74 100644 --- a/src/app/domain-annotations/prop.ts +++ b/src/app/domain-annotations/prop.ts @@ -28,7 +28,7 @@ namespace DomainAnnotations { return !!model && Model.hasPdbId(model); } - export function fromJson(model: Model, data: any) { + export function fromJson(model: Model, data: any): DomainAnnotations { const info = PropertyWrapper.createInfo(); const domainMap = createdomainMapFromJson(model, data); return { info, data: domainMap }; @@ -88,7 +88,12 @@ export const DomainAnnotationsProvider: CustomModelProperty.Provider DomainAnnotations.isApplicable(data), obtain: async (ctx: CustomProperty.Context, data: Model, props: Partial) => { const p = { ...PD.getDefaultValues(DomainAnnotationsParams), ...props }; - return await DomainAnnotations.fromServer(ctx, data, p); + try { + return await DomainAnnotations.fromServer(ctx, data, p); + } catch { + console.error('Could not obtain domain annotations'); + return { value: DomainAnnotations.fromJson(data, {}) }; + } }, });