After more thoughts, I believe navigator.crossOriginStorage.requestFileHandles() should NOT throw NotFoundError when COS files are not found. It should simply return an empty list instead.
It's not an exception to not have found files, it's okay to not have them in the cache. A user saying no to the prompt OR an unexpected internal error should indeed throw exceptions.
const hash = {
algorithm: "SHA-256",
value: "8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4",
};
let handle;
try {
[handle] = await navigator.crossOriginStorage.requestFileHandles([hash]);
} catch (err) {
if (err.name === "NotAllowedError")
console.log("The user did not grant permission to access the file.");
}
if (handle) {
const fileBlob = await handle.getFile();
// Do something with the blob.
} else {
console.log("The file was not found in Cross-Origin Storage.");
}