File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -163,10 +163,18 @@ export default () => {
163
163
}
164
164
const fetchImages = async ( imageUrls , lastOpenedImage ) => {
165
165
try {
166
- const fetchPromises = imageUrls . map ( url =>
167
- fetch ( url . src ) . then ( response => response . blob ( ) )
168
- . then ( blob => ( { ...url , src : URL . createObjectURL ( blob ) } ) )
169
- ) ;
166
+ const fetchPromises = imageUrls . map ( async url => {
167
+ const response = await fetch ( url . src ) ;
168
+ if ( ! response . ok ) {
169
+ if ( response . status === 404 ) {
170
+ const errorMSG = `${ t ( "error.image_not_found" ) } : ${ url . src } ` ;
171
+ throw new Error ( errorMSG ) ;
172
+ }
173
+ }
174
+ const blob = await response . blob ( ) ;
175
+ return { ...url , src : URL . createObjectURL ( blob ) } ;
176
+ } ) ;
177
+
170
178
const images = await Promise . all ( fetchPromises ) ;
171
179
const imageURLSrcs = imageUrls . map ( url => decodeURIComponent ( url . src . split ( '/' ) . pop ( ) ) ) ;
172
180
let image_annotations = await getImagesAnnotation ( { image_names : imageURLSrcs } ) ;
@@ -195,6 +203,7 @@ export default () => {
195
203
setIsLoading ( false )
196
204
} catch ( error ) {
197
205
showSnackbar ( error . message , 'error' ) ;
206
+ setIsLoading ( false ) ;
198
207
} finally {
199
208
setLoading ( false ) ;
200
209
}
You can’t perform that action at this time.
0 commit comments