@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/servers.cjs CHANGED
@@ -3423,29 +3423,23 @@ var DicomReceiver = class _DicomReceiver extends events.EventEmitter {
3423
3423
  }
3424
3424
  /** Parses a DICOM file and emits INSTANCE_RECEIVED or error. */
3425
3425
  emitInstanceReceived(filePath, fileSize, data, ctx) {
3426
+ const errorCtx = {
3427
+ filePath,
3428
+ associationId: ctx.associationId,
3429
+ associationDir: ctx.associationDir,
3430
+ callingAE: data.callingAE,
3431
+ calledAE: data.calledAE,
3432
+ source: data.source
3433
+ };
3426
3434
  void DicomInstance.open(filePath).then((openResult) => {
3427
3435
  if (!openResult.ok) {
3428
- this.emit("error", {
3429
- error: openResult.error,
3430
- filePath,
3431
- associationId: ctx.associationId,
3432
- associationDir: ctx.associationDir,
3433
- callingAE: data.callingAE,
3434
- calledAE: data.calledAE,
3435
- source: data.source
3436
- });
3436
+ this.emit("error", { error: openResult.error, ...errorCtx });
3437
3437
  return;
3438
3438
  }
3439
- this.emit("INSTANCE_RECEIVED", {
3440
- filePath,
3441
- fileSize,
3442
- associationId: ctx.associationId,
3443
- associationDir: ctx.associationDir,
3444
- callingAE: data.callingAE,
3445
- calledAE: data.calledAE,
3446
- source: data.source,
3447
- instance: openResult.value
3448
- });
3439
+ this.emit("INSTANCE_RECEIVED", { ...errorCtx, fileSize, instance: openResult.value });
3440
+ }).catch((thrown) => {
3441
+ const error = thrown instanceof Error ? thrown : new Error(String(thrown));
3442
+ this.emit("error", { error, ...errorCtx });
3449
3443
  });
3450
3444
  }
3451
3445
  /** Returns worker to idle pool on association complete, emits summary. */