Commit d179696 1 parent c8270ac commit d179696 Copy full SHA for d179696
File tree 1 file changed +20
-2
lines changed
src/main/webapp/ui/src/eln/gallery
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -804,15 +804,33 @@ export function useGalleryActions(): {|
804
804
) ;
805
805
}
806
806
if ( rejected . length > 0 ) {
807
+ const rejectedResponses = await Promise . all (
808
+ rejected . map ( async ( response ) => {
809
+ try {
810
+ const data = Parsers . objectPath (
811
+ [ "response" , "data" ] ,
812
+ response
813
+ ) . elseThrow ( ) ;
814
+ if ( ! ( data instanceof Blob ) )
815
+ throw new Error ( "Response is not a blob" ) ;
816
+ const json : mixed = JSON . parse ( await data . text ( ) ) ;
817
+ return Parsers . objectPath ( [ "message" ] , json )
818
+ . flatMap ( Parsers . isString )
819
+ . elseThrow ( ) ;
820
+ } catch ( e ) {
821
+ return Promise . resolve ( e . message ) ;
822
+ }
823
+ } )
824
+ ) ;
807
825
addAlert (
808
826
mkAlert ( {
809
827
variant : "error" ,
810
828
message : `Failed to download ${
811
829
fulfilled . length > 0 ? "some of " : ""
812
830
} the files.`,
813
- details : rejected . map ( ( e ) => ( {
831
+ details : rejectedResponses . map ( ( errorMsg ) => ( {
814
832
variant : "error" ,
815
- title : e . message ,
833
+ title : errorMsg ,
816
834
} ) ) ,
817
835
} )
818
836
) ;
You can’t perform that action at this time.
0 commit comments