Properly catch errors from Javascript-Voronoi

This commit is contained in:
Wuzzy 2023-10-26 12:53:43 +02:00
parent 8edfae92cb
commit f60d68f022

View File

@ -693,10 +693,16 @@ function getVoronoiDiagram(points, recalculate) {
diagram = voronoi.compute(sites, vbbox); diagram = voronoi.compute(sites, vbbox);
} catch(err) { } catch(err) {
diagram = null; diagram = null;
console.error("Error when calling voronoi.compute from Javascript-Voronoi library!\n"+ if (err instanceof Error) {
"* exception name: "+err.name+"\n"+ console.error("Error when calling voronoi.compute from Javascript-Voronoi library!\n"+
"* exception message: "+err.message+"\n"+ "* exception name: "+err.name+"\n"+
"* stack: "+err.stack); "* exception message: "+err.message+"\n"+
"* stack:\n"+err.stack);
} else {
console.error("Error when calling voronoi.compute from Javascript-Voronoi library!");
console.error(err);
throw err;
}
} finally { } finally {
cachedVoronoiDiagram = diagram; cachedVoronoiDiagram = diagram;
return diagram; return diagram;
@ -1780,9 +1786,9 @@ inputImportSubmit.onclick = function() {
} else { } else {
importMessage("Import failed due to internal error of type '"+err.name+"': "+err.message); importMessage("Import failed due to internal error of type '"+err.name+"': "+err.message);
console.error("Internal error while calling JSON.parse during import!\n"+ console.error("Internal error while calling JSON.parse during import!\n"+
"* name: "+err.name+"\n"+ "* exception name: "+err.name+"\n"+
"* message: "+err.message+"\n"+ "* exception message: "+err.message+"\n"+
"* stack: "+err.stack); "* stack:\n"+err.stack);
} }
return; return;
} }