simplify logging

This commit is contained in:
Simon Knott 2024-11-29 12:31:33 +01:00
parent 8055eeb14d
commit 5ce5fc0e20
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -159,24 +159,20 @@ async function downloadBrotli(title: string, browserDirectory: string, url: stri
tarFs.extract(browserDirectory) tarFs.extract(browserDirectory)
); );
} catch (error) { } catch (error) {
if (error?.code === 'ECONNRESET') { if (error?.code === 'ECONNRESET')
debugLogger.log('install', `-- download failed, server closed connection`);
throw new Error(`Download failed: server closed connection. URL: ${url}`); throw new Error(`Download failed: server closed connection. URL: ${url}`);
}
debugLogger.log('install', `-- download failed, unexpected error`);
throw new Error(`Download failed: ${error?.message ?? error}. URL: ${url}`); throw new Error(`Download failed: ${error?.message ?? error}. URL: ${url}`);
} }
if (downloadedBytes !== totalBytes) { if (downloadedBytes !== totalBytes)
debugLogger.log('install', `-- download failed, size mismatch: ${downloadedBytes} != ${totalBytes}`);
throw new Error(`Download failed: size mismatch, file size: ${downloadedBytes}, expected size: ${totalBytes} URL: ${url}`); throw new Error(`Download failed: size mismatch, file size: ${downloadedBytes}, expected size: ${totalBytes} URL: ${url}`);
}
debugLogger.log('install', `-- download complete, size: ${downloadedBytes}`); debugLogger.log('install', `-- download complete, size: ${downloadedBytes}`);
return { error: null }; return { error: null };
} catch (error) { } catch (error) {
debugLogger.log('install', `-- ${error.message}`);
return { error }; return { error };
} }
} }