From 5abdf58b4843bd8c51e81b05f3cd5e738f205e74 Mon Sep 17 00:00:00 2001 From: Vinicius Reis Date: Mon, 6 Jun 2022 17:34:10 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(#2463):=20emit=20error=20when=20im?= =?UTF-8?q?age=20loading=20fails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vinicius Reis --- src/nodes/ImageView.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nodes/ImageView.vue b/src/nodes/ImageView.vue index 7d2f8689d..71939b9e7 100644 --- a/src/nodes/ImageView.vue +++ b/src/nodes/ImageView.vue @@ -121,7 +121,7 @@ const getQueryVariable = (src, variable) => { } } -class ErrorLoadImage extends Error { +class LoadImageError extends Error { constructor(reason, imageUrl) { super(reason?.message || t('text', 'Failed to load')) @@ -245,7 +245,7 @@ export default { resolve(imageUrl) } img.onerror = (e) => { - reject(new ErrorLoadImage(e, imageUrl)) + reject(new LoadImageError(e, imageUrl)) } img.src = imageUrl }) @@ -256,9 +256,11 @@ export default { this.loaded = true this.errorMessage = err.message - if (err instanceof ErrorLoadImage) { + if (err instanceof LoadImageError) { this.errorMessage = `${this.errorMessage} [${this.src}]` } + + this.$emit('error', { error: err, src: this.src }) }, updateAlt(event) { this.updateAttributes({