Small fixes to the 'generateCache' script

This commit is contained in:
Pieter Vander Vennet 2021-10-03 02:11:06 +02:00
parent 5bcb879dfe
commit 23136f7e7a
4 changed files with 11 additions and 14 deletions

View file

@ -97,17 +97,16 @@ async function downloadRaw(targetdir: string, r: TileRange, theme: LayoutConfig,
try {
const json = await ScriptUtils.DownloadJSON(url)
if (json.elements.length === 0) {
console.log("Got an empty response!")
if ((<string>json.remark ?? "").startsWith("runtime error")) {
console.error("Got a runtime error: ", json.remark)
failed++;
}
if ((<string>json.remark ?? "").startsWith("runtime error")) {
console.error("Got a runtime error: ", json.remark)
failed++;
}else if (json.elements.length === 0) {
console.log("Got an empty response! Writing anyway")
}
} else {
console.log("Got the response - writing to ", filename)
writeFileSync(filename, JSON.stringify(json, null, " "));
}
} catch (err) {
console.log(url)
console.log("Could not download - probably hit the rate limit; waiting a bit. (" + err + ")")