mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 17:51:20 -08:00
fix(dash): [PKG-DASH-CLEANUP-01] preserve first cleanup exception
This commit is contained in:
1 parent
1c522f181b
commit
25faf88e80
23 files changed
+49546
-147
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import type { Cleanup, Valid } from './types'
|
||||
|
||||
export function runCleanups(actions: Cleanup[], current: Valid = () => true): void {
|
||||
let failed = false
|
||||
let failure: unknown
|
||||
for (const action of actions) {
|
||||
if (!current())
|
||||
break
|
||||
try {
|
||||
action()
|
||||
}
|
||||
catch (error) {
|
||||
if (!failed) {
|
||||
failed = true
|
||||
failure = error
|
||||
}
|
||||
}
|
||||
}
|
||||
if (failed)
|
||||
throw failure
|
||||
}
|
||||
Reference in new issue
Block a user