Trying to set up KML Import in Cesium where I can notify the user if there’s an error when running kmlSource.load
, which looks like
const kmlSource = new KmlDataSource({
canvas: viewer.scene.canvas,
camera: viewer.scene.camera,
});
kmlSource.load(kmlFile, {
clampToGround: true,
}).then(() => {
viewer.dataSources.add(kmlSource);
}).catch() => {
alert("Error!")
})
But I get this error in response:
cesiumVue.vue?d02c:177 Uncaught (in promise) TypeError: kmlSource.load(...).then(...).catch is not a function at eval
And the function never uses the catch()
to, well, capture runtime errors.
How can I capture a runtime error when loading a KML file to see if KML importing failed?