js: cleanup error throwing to always use new Error (#504)

This commit is contained in:
Brandon Liu
2024-12-13 14:42:13 +08:00
committed by GitHub
parent 7ed6377031
commit 5b075048cc
4 changed files with 14 additions and 14 deletions

View File

@@ -42,7 +42,7 @@ async function nativeDecompress(
if (compression === Compression.Gzip) {
return zlib.gunzipSync(buf);
}
throw Error("Compression method not supported");
throw new Error("Compression method not supported");
}
// Lambda needs to run with 512MB, empty function takes about 70
@@ -90,7 +90,7 @@ class S3Source implements Source {
const arr = await resp.Body?.transformToByteArray();
if (!arr) throw Error("Failed to read S3 response body");
if (!arr) throw new Error("Failed to read S3 response body");
return {
data: arr.buffer,

View File

@@ -36,7 +36,7 @@ async function nativeDecompress(
const result = stream?.pipeThrough(new DecompressionStream("gzip"));
return new Response(result).arrayBuffer();
}
throw Error("Compression method not supported");
throw new Error("Compression method not supported");
}
const CACHE = new ResolvedValueCache(25, undefined, nativeDecompress);