@fedify/vocab-tools 2.0.29-dev.2121 → 2.0.29-dev.2143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/property.ts CHANGED
@@ -251,7 +251,16 @@ async function* generateProperty(
251
251
  ${JSON.stringify(property.compactName)}];
252
252
  const doc = Array.isArray(prop) ? prop[0] : prop;
253
253
  if (doc != null && typeof doc === "object" && "@context" in doc) {
254
- v = await this.#${property.singularName}_fromJsonLd(doc, options);
254
+ try {
255
+ v = await this.#${property.singularName}_fromJsonLd(doc, options);
256
+ } catch (error) {
257
+ if (!options.suppressError) throw error;
258
+ getLogger(["fedify", "vocab"]).debug(
259
+ "Failed to parse embedded value of {property}: {error}",
260
+ { property: ${JSON.stringify(property.uri)}, error },
261
+ );
262
+ return null;
263
+ }
255
264
  }
256
265
  }
257
266
  `;
@@ -350,7 +359,18 @@ async function* generateProperty(
350
359
  ${JSON.stringify(property.compactName)}];
351
360
  const obj = Array.isArray(prop) ? prop[i] : prop;
352
361
  if (obj != null && typeof obj === "object" && "@context" in obj) {
353
- v = await this.#${property.singularName}_fromJsonLd(obj, options);
362
+ try {
363
+ v = await this.#${property.singularName}_fromJsonLd(obj, options);
364
+ } catch (error) {
365
+ if (!options.suppressError) throw error;
366
+ getLogger(["fedify", "vocab"]).debug(
367
+ "Failed to parse embedded value of {property} at index {index}: {error}",
368
+ { property: ${
369
+ JSON.stringify(property.uri)
370
+ }, index: i, error },
371
+ );
372
+ continue;
373
+ }
354
374
  }
355
375
  }
356
376
  `;