How to catch KML import errors?

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,
kmlSource.load(kmlFile, {
        clampToGround: true,
}).then(() => {
}).catch() => {

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?

Ok, so the error here is that the specific block of code used in KmlDataSource is not a standard Promise but a third party promise based on when, which uses otherwise instead of catch for errors.

This should probably be reported on Github as an error since it affects typescript implementation, given that it is expecting a Promise<KmlDataSource> but it’s actually a when.

Thanks for reporting this. I’ve opened an issue in CesiumJS here to discuss the typeing issue for the when promises: Typescript errors related to when not conforming to the Promise standard · Issue #9297 · CesiumGS/cesium · GitHub