@@ -416,10 +416,17 @@ func (d *DeleteBatchError) Error() string {
416416 return fmt .Sprintf ("%v: %v messages failed to delete" , d .Err , len (d .Info ))
417417}
418418
419+ type DeleteNBatchError struct {
420+ Errors []error
421+ Info []DeleteBatchErrorEntry
419422}
420423
421- func (d * DeleteBatchError ) Info () []DeleteBatchErrorInfo {
422- return d .info
424+ func (s * DeleteNBatchError ) Error () string {
425+ var allErrors string
426+ for _ , err := range s .Errors {
427+ allErrors += fmt .Sprintf ("%s\n " , err .Error ())
428+ }
429+ return fmt .Sprintf ("error(s) deleting batches:\n %s" , allErrors )
423430}
424431
425432// DeleteBatch deletes multiple messages from an SQS queue in a single batch
@@ -471,7 +478,9 @@ func (s *SQS) DeleteNBatch(ctx context.Context, queueURL string, receiptHandles
471478 times = int (math .Ceil (float64 (receiptCount ) / float64 (maxlen )))
472479 )
473480
474- info := make ([]DeleteBatchErrorInfo , 0 )
481+ allErrors := make ([]error , 0 )
482+ allInfo := make ([]DeleteBatchErrorEntry , 0 )
483+
475484 batchesDeleted := 0
476485
477486 for i := 0 ; i < times ; i ++ {
@@ -484,14 +493,16 @@ func (s *SQS) DeleteNBatch(ctx context.Context, queueURL string, receiptHandles
484493 err := s .DeleteBatch (ctx , queueURL , receipt_batch )
485494 var dbe * DeleteBatchError
486495 if errors .As (err , & dbe ) {
487- info = append (info , dbe .Info ()... )
496+ allErrors = append (allErrors , err )
497+ allInfo = append (allInfo , dbe .Info ... )
488498 }
489499 batchesDeleted ++
490500 }
491501
492- if len (info ) > 0 {
493- return batchesDeleted , & DeleteBatchError {
494- info : info ,
502+ if len (allErrors ) > 0 {
503+ return batchesDeleted , & DeleteNBatchError {
504+ Errors : allErrors ,
505+ Info : allInfo ,
495506 }
496507 }
497508 return batchesDeleted , nil
0 commit comments