@ubercode/dcmtk 0.11.0 → 0.11.1

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.cjs CHANGED
@@ -37052,29 +37052,23 @@ var DicomReceiver = class _DicomReceiver extends events.EventEmitter {
37052
37052
  }
37053
37053
  /** Parses a DICOM file and emits INSTANCE_RECEIVED or error. */
37054
37054
  emitInstanceReceived(filePath, fileSize, data, ctx) {
37055
+ const errorCtx = {
37056
+ filePath,
37057
+ associationId: ctx.associationId,
37058
+ associationDir: ctx.associationDir,
37059
+ callingAE: data.callingAE,
37060
+ calledAE: data.calledAE,
37061
+ source: data.source
37062
+ };
37055
37063
  void DicomInstance.open(filePath).then((openResult) => {
37056
37064
  if (!openResult.ok) {
37057
- this.emit("error", {
37058
- error: openResult.error,
37059
- filePath,
37060
- associationId: ctx.associationId,
37061
- associationDir: ctx.associationDir,
37062
- callingAE: data.callingAE,
37063
- calledAE: data.calledAE,
37064
- source: data.source
37065
- });
37065
+ this.emit("error", { error: openResult.error, ...errorCtx });
37066
37066
  return;
37067
37067
  }
37068
- this.emit("INSTANCE_RECEIVED", {
37069
- filePath,
37070
- fileSize,
37071
- associationId: ctx.associationId,
37072
- associationDir: ctx.associationDir,
37073
- callingAE: data.callingAE,
37074
- calledAE: data.calledAE,
37075
- source: data.source,
37076
- instance: openResult.value
37077
- });
37068
+ this.emit("INSTANCE_RECEIVED", { ...errorCtx, fileSize, instance: openResult.value });
37069
+ }).catch((thrown) => {
37070
+ const error = thrown instanceof Error ? thrown : new Error(String(thrown));
37071
+ this.emit("error", { error, ...errorCtx });
37078
37072
  });
37079
37073
  }
37080
37074
  /** Returns worker to idle pool on association complete, emits summary. */