@@ -69,18 +69,7 @@ export default class FragmentLoader {
69
69
this . loader . destroy ( ) ;
70
70
}
71
71
if ( frag . gap ) {
72
- frag . stats . aborted = true ;
73
- frag . stats . retry ++ ;
74
- reject (
75
- new LoadError ( {
76
- type : ErrorTypes . MEDIA_ERROR ,
77
- details : ErrorDetails . FRAG_GAP ,
78
- fatal : false ,
79
- frag,
80
- error : new Error ( 'GAP tag found' ) ,
81
- networkDetails : null ,
82
- } )
83
- ) ;
72
+ reject ( createGapLoadError ( frag ) ) ;
84
73
return ;
85
74
}
86
75
const loader =
@@ -191,19 +180,7 @@ export default class FragmentLoader {
191
180
this . loader . destroy ( ) ;
192
181
}
193
182
if ( frag . gap || part . gap ) {
194
- frag . stats . aborted = true ;
195
- frag . stats . retry ++ ;
196
- reject (
197
- new LoadError ( {
198
- type : ErrorTypes . MEDIA_ERROR ,
199
- details : ErrorDetails . FRAG_GAP ,
200
- fatal : false ,
201
- frag,
202
- part,
203
- error : new Error ( `GAP ${ frag . gap ? 'tag' : 'attribute' } found` ) ,
204
- networkDetails : null ,
205
- } )
206
- ) ;
183
+ reject ( createGapLoadError ( frag , part ) ) ;
207
184
return ;
208
185
}
209
186
const loader =
@@ -373,6 +350,22 @@ function createLoaderContext(
373
350
return loaderContext ;
374
351
}
375
352
353
+ function createGapLoadError ( frag : Fragment , part ?: Part ) : LoadError {
354
+ const error = new Error ( `GAP ${ frag . gap ? 'tag' : 'attribute' } found` ) ;
355
+ const errorData : FragLoadFailResult = {
356
+ type : ErrorTypes . MEDIA_ERROR ,
357
+ details : ErrorDetails . FRAG_GAP ,
358
+ fatal : false ,
359
+ frag,
360
+ error,
361
+ networkDetails : null ,
362
+ } ;
363
+ if ( part ) {
364
+ errorData . part = part ;
365
+ }
366
+ return new LoadError ( errorData ) ;
367
+ }
368
+
376
369
export class LoadError extends Error {
377
370
public readonly data : FragLoadFailResult ;
378
371
constructor ( data : FragLoadFailResult ) {
0 commit comments