Skip to content

Commit

Permalink
Do not crash on Domain annotations 404
Browse files Browse the repository at this point in the history
  • Loading branch information
midlik committed Nov 21, 2024
1 parent d24d832 commit 1e6dbb9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/domain-annotations/prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -88,7 +88,12 @@ export const DomainAnnotationsProvider: CustomModelProperty.Provider<DomainAnnot
isApplicable: (data: Model) => DomainAnnotations.isApplicable(data),
obtain: async (ctx: CustomProperty.Context, data: Model, props: Partial<DomainAnnotationsProps>) => {
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, {}) };
}
},
});

Expand Down

0 comments on commit 1e6dbb9

Please sign in to comment.