@@ -6,6 +6,7 @@ export async function callUntilEnd<T extends boolean>(
6
6
: ( end : ( ) => boolean ) => void | boolean ,
7
7
timeout : number ,
8
8
immediate : boolean = false ,
9
+ continueEvenError : boolean = false ,
9
10
promise : T = false as T
10
11
) : Promise < void > {
11
12
return new Promise ( ( resolve , reject ) => {
@@ -26,11 +27,16 @@ export async function callUntilEnd<T extends boolean>(
26
27
_dev . warn (
27
28
"fastjs/utils/doUntilEnd" ,
28
29
"An error occurred while executing the function" ,
29
- error
30
+ [ error . toString ( ) ]
30
31
) ;
31
32
}
32
- reject ( error ) ;
33
- end = true ;
33
+ if ( continueEvenError ) {
34
+ setTimeout ( callFunc , timeout ) ;
35
+ console . error ( error ) ;
36
+ } else {
37
+ reject ( error ) ;
38
+ end = true ;
39
+ }
34
40
}
35
41
}
36
42
} ) ;
@@ -39,9 +45,8 @@ export async function callUntilEnd<T extends boolean>(
39
45
export function callPromiseUntilEnd (
40
46
func : ( end : ( ) => boolean ) => Promise < void | boolean > ,
41
47
timeout : number = 1000 ,
42
- immediate : boolean = false
48
+ immediate : boolean = false ,
49
+ continueEvenError : boolean = false
43
50
) : Promise < void > {
44
- return new Promise ( ( resolve ) => {
45
- callUntilEnd ( func , timeout , immediate , true ) . then ( resolve ) ;
46
- } ) ;
51
+ return callUntilEnd ( func , timeout , immediate , true ) ;
47
52
}
0 commit comments