@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.js CHANGED
@@ -37027,29 +37027,23 @@ var DicomReceiver = class _DicomReceiver extends EventEmitter {
37027
37027
  }
37028
37028
  /** Parses a DICOM file and emits INSTANCE_RECEIVED or error. */
37029
37029
  emitInstanceReceived(filePath, fileSize, data, ctx) {
37030
+ const errorCtx = {
37031
+ filePath,
37032
+ associationId: ctx.associationId,
37033
+ associationDir: ctx.associationDir,
37034
+ callingAE: data.callingAE,
37035
+ calledAE: data.calledAE,
37036
+ source: data.source
37037
+ };
37030
37038
  void DicomInstance.open(filePath).then((openResult) => {
37031
37039
  if (!openResult.ok) {
37032
- this.emit("error", {
37033
- error: openResult.error,
37034
- filePath,
37035
- associationId: ctx.associationId,
37036
- associationDir: ctx.associationDir,
37037
- callingAE: data.callingAE,
37038
- calledAE: data.calledAE,
37039
- source: data.source
37040
- });
37040
+ this.emit("error", { error: openResult.error, ...errorCtx });
37041
37041
  return;
37042
37042
  }
37043
- this.emit("INSTANCE_RECEIVED", {
37044
- filePath,
37045
- fileSize,
37046
- associationId: ctx.associationId,
37047
- associationDir: ctx.associationDir,
37048
- callingAE: data.callingAE,
37049
- calledAE: data.calledAE,
37050
- source: data.source,
37051
- instance: openResult.value
37052
- });
37043
+ this.emit("INSTANCE_RECEIVED", { ...errorCtx, fileSize, instance: openResult.value });
37044
+ }).catch((thrown) => {
37045
+ const error = thrown instanceof Error ? thrown : new Error(String(thrown));
37046
+ this.emit("error", { error, ...errorCtx });
37053
37047
  });
37054
37048
  }
37055
37049
  /** Returns worker to idle pool on association complete, emits summary. */