Reading the output directory is guarded and the failure is reported, but the check for whether anything is left in it is not, so an unreadable directory surfaces as a throw regardless.
const entries = await getEntries(dir, logger); // catches, logs, returns []
// ...
const remaining = await readdir(dir); // same directory, unguarded
The guard's shape says the failure is handled. It isn't: it's reported, then hit again a few lines later, and the second read is what the caller sees.
The decision is which of the two the guard was meant to be. Either the failure is survivable, in which case the second read needs the same treatment, or it isn't, in which case the guard should go and let it surface once.
Reading the output directory is guarded and the failure is reported, but the check for whether anything is left in it is not, so an unreadable directory surfaces as a throw regardless.
The guard's shape says the failure is handled. It isn't: it's reported, then hit again a few lines later, and the second read is what the caller sees.
The decision is which of the two the guard was meant to be. Either the failure is survivable, in which case the second read needs the same treatment, or it isn't, in which case the guard should go and let it surface once.