@@ -832,22 +832,21 @@ func handleStatusErrors(
832
832
failed chan error ,
833
833
prefix string ,
834
834
) {
835
- if status .Code != "" || len ( status . Errors ) > 0 { //ToDo refine error handling to cover all the cases with detailed messages
835
+ if status .Code == "bundle_error" {
836
836
if status .HTTPCode == "" {
837
- failed <- fmt . Errorf ( "%s failed: %s" , prefix , status . Code )
837
+ failed <- formatStatusError ( prefix , status )
838
838
return
839
839
}
840
840
code , err := status .HTTPCode .Int64 ()
841
- if err == nil && ( code >= 400 && code < 500 ) && ! isTemporaryError (code ) {
841
+ if err == nil && code >= 400 && code < 500 && ! isTemporaryError (code ) {
842
842
// Fail for error codes in the range 400-500 excluding temporary errors
843
- failed <- fmt .Errorf ("%s failed: %s" , prefix , status .Code )
843
+ failed <- formatStatusError (prefix , status )
844
+ return
845
+ }
846
+ if err != nil {
847
+ failed <- formatStatusError (prefix , status )
844
848
return
845
849
}
846
- }
847
-
848
- if len (status .Errors ) > 0 {
849
- failed <- fmt .Errorf ("%s failed: %w" , prefix , errors .Join (status .Errors ... ))
850
- return
851
850
}
852
851
}
853
852
@@ -859,3 +858,22 @@ func isTemporaryError(code int64) bool {
859
858
}
860
859
return false
861
860
}
861
+
862
+ func formatStatusError (prefix string , status bundle.Status ) error {
863
+ var b strings.Builder
864
+ b .WriteString (fmt .Sprintf ("%s failed:" , prefix ))
865
+ b .WriteString (fmt .Sprintf (" Name: %s" , status .Name ))
866
+ if status .Code != "" {
867
+ b .WriteString (fmt .Sprintf (", Code: %s" , status .Code ))
868
+ }
869
+ if status .Message != "" {
870
+ b .WriteString (fmt .Sprintf (", Message: %s" , status .Message ))
871
+ }
872
+ if status .HTTPCode != "" {
873
+ b .WriteString (fmt .Sprintf (", HTTPCode: %s" , status .HTTPCode ))
874
+ }
875
+ if len (status .Errors ) > 0 {
876
+ b .WriteString (fmt .Sprintf (", Errors: %v" , status .Errors ))
877
+ }
878
+ return errors .New (b .String ())
879
+ }
0 commit comments