Alert on invalid filename (fixes #1)

This commit is contained in:
Antonia 2025-03-18 20:02:01 +01:00
parent 13900c8092
commit 634df5ebf4

View file

@ -229,9 +229,14 @@ async function pickDirectory(e){
return;
}
const dat = {type: "FeatureCollection", features: geojsons};
const file = await dirHandle.getFileHandle(`${filename}.geojson`, {
create: true
});
try {
const file = await dirHandle.getFileHandle(`${filename}.geojson`, {
create: true
});
} catch (error) {
alert(`Could not open file: ${error.message}`);
return
}
const blob = new Blob([JSON.stringify(dat)]);
const writableStream = await file.createWritable();
await writableStream.write(blob);