Improve error logging a bit

This commit is contained in:
Wuzzy 2023-10-26 12:27:53 +02:00
parent ce5ee5eeb5
commit ba29a0a0f5

View File

@ -691,11 +691,15 @@ function getVoronoiDiagram(points, recalculate) {
}
try {
diagram = voronoi.compute(sites, vbbox);
} catch(err) {
diagram = null;
console.log("Error when calling voronoi.compute from Javascript-Voronoi library!");
console.log("* exception name: "+err.name);
console.log("* exception message: "+err.message);
console.log("* stack: "+err.stack);
} finally {
cachedVoronoiDiagram = diagram;
return diagram;
} catch {
cachedVoronoiDiagram = null;
return null;
}
} else {
return cachedVoronoiDiagram;
@ -1765,11 +1769,25 @@ inputImportSubmit.onclick = function() {
let parsedJSON;
try {
parsedJSON = JSON.parse(importStr, reviver);
} catch {
importMessage("Import failed. Not a valid JSON object.");
} catch(err) {
if (err.name === "SyntaxError") {
let details = err.message;
if (!details) {
details = "<none given>";
}
importMessage("Import failed. Not a syntactically valid JSON object. Details: "+details);
} else {
importMessage("Import failed due to internal error of type '"+err.name+"': "+err.message);
console.log("Internal error while calling JSON.parse during import!");
console.log("* name: "+err.name);
console.log("* message: "+err.message);
console.log("* stack: "+err.stack);
}
return;
}
if (typeof parsedJSON !== "object") {
importMessage("Import failed. Not a valid JSON object.");
importMessage("Import failed. JSON.parse didnt return an object but it didnt throw an exception?!");
console.log("ERROR: JSON.parse didn't return an object although it didn't throw an exception");
return;
}