aai-lark-bridge 0.2.7 → 0.2.9

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/dist/index.js CHANGED
@@ -385,15 +385,31 @@ var log = {
385
385
  const stack = err instanceof Error ? err.stack : void 0;
386
386
  const apiData = err?.response?.data;
387
387
  const apiStatus = err?.response?.status;
388
+ const code = err?.code;
389
+ const cause = err instanceof Error && "cause" in err && err.cause !== void 0 ? describeCause(err.cause) : void 0;
388
390
  emit("error", phase, "fail", {
389
391
  ...fields,
390
392
  err: message,
393
+ ...typeof code === "string" ? { code } : {},
391
394
  apiStatus,
392
395
  apiData,
393
- stack
396
+ stack,
397
+ ...cause !== void 0 ? { cause } : {}
394
398
  });
395
399
  }
396
400
  };
401
+ function describeCause(cause) {
402
+ if (!(cause instanceof Error)) return String(cause);
403
+ const c = cause;
404
+ return {
405
+ name: c.name,
406
+ message: c.message,
407
+ ...c.code !== void 0 ? { code: c.code } : {},
408
+ ...c.errno !== void 0 ? { errno: c.errno } : {},
409
+ ...c.syscall !== void 0 ? { syscall: c.syscall } : {},
410
+ ...c.stack ? { stack: c.stack } : {}
411
+ };
412
+ }
397
413
  function redactDiagnosticText(text) {
398
414
  let out = redactJsonCredentialText(text);
399
415
  out = redactResourceText(out);