Merge pull request #1867 from umap-project/catch-xml-error

fix: show message in case of xml parsing error
This commit is contained in:
Yohan Boniface 2024-05-29 20:17:40 +02:00 committed by GitHub
commit 3a12865d62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -933,7 +933,14 @@ U.DataLayer = L.Evented.extend({
},
rawToGeoJSON: function (c, type, callback) {
const toDom = (x) => new DOMParser().parseFromString(x, 'text/xml')
const toDom = (x) => {
const doc = new DOMParser().parseFromString(x, 'text/xml')
const errorNode = doc.querySelector('parsererror')
if (errorNode) {
this.map.alert.open({ content: L._('Cannot parse data'), level: 'error' })
}
return doc
}
// TODO add a duck typing guessType
if (type === 'csv') {