зеркало из https://github.com/nextcloud/text.git
✨ (#2463): emit error when image loading fails
Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
This commit is contained in:
Родитель
a54c52dde7
Коммит
5abdf58b48
|
@ -121,7 +121,7 @@ const getQueryVariable = (src, variable) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ErrorLoadImage extends Error {
|
class LoadImageError extends Error {
|
||||||
|
|
||||||
constructor(reason, imageUrl) {
|
constructor(reason, imageUrl) {
|
||||||
super(reason?.message || t('text', 'Failed to load'))
|
super(reason?.message || t('text', 'Failed to load'))
|
||||||
|
@ -245,7 +245,7 @@ export default {
|
||||||
resolve(imageUrl)
|
resolve(imageUrl)
|
||||||
}
|
}
|
||||||
img.onerror = (e) => {
|
img.onerror = (e) => {
|
||||||
reject(new ErrorLoadImage(e, imageUrl))
|
reject(new LoadImageError(e, imageUrl))
|
||||||
}
|
}
|
||||||
img.src = imageUrl
|
img.src = imageUrl
|
||||||
})
|
})
|
||||||
|
@ -256,9 +256,11 @@ export default {
|
||||||
this.loaded = true
|
this.loaded = true
|
||||||
this.errorMessage = err.message
|
this.errorMessage = err.message
|
||||||
|
|
||||||
if (err instanceof ErrorLoadImage) {
|
if (err instanceof LoadImageError) {
|
||||||
this.errorMessage = `${this.errorMessage} [${this.src}]`
|
this.errorMessage = `${this.errorMessage} [${this.src}]`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$emit('error', { error: err, src: this.src })
|
||||||
},
|
},
|
||||||
updateAlt(event) {
|
updateAlt(event) {
|
||||||
this.updateAttributes({
|
this.updateAttributes({
|
||||||
|
|
Загрузка…
Ссылка в новой задаче