diff --git a/packages/common/jsonld.js b/packages/common/jsonld.js index 3ab916fe7a105c44c7e33f8bc5a9b6b66e8eb651..a259b57009c1d3e09aed66a24a6c4228cf67c2c3 100644 --- a/packages/common/jsonld.js +++ b/packages/common/jsonld.js @@ -134,11 +134,23 @@ export default class JSONLD { } getApiUrlForIdentifier(identifier) { - return this.getEntityForIdentifier(identifier)["@entryPoint"]; + const entity = this.getEntityForIdentifier(identifier); + + if (entity === undefined || entity["@entryPoint"] === undefined) { + throw new Error(`Entity with identifier "${identifier}" not found!`); + } + + return entity["@entryPoint"]; } getApiUrlForEntityName(entityName) { - return this.getEntityForEntityName(entityName)["@entryPoint"]; + const entity = this.getEntityForEntityName(entityName); + + if (entity === undefined || entity["@entryPoint"] === undefined) { + throw new Error(`Entity "${entityName}" not found!`); + } + + return entity["@entryPoint"]; } getEntityNameForIdentifier(identifier) {