From 5abdf58b4843bd8c51e81b05f3cd5e738f205e74 Mon Sep 17 00:00:00 2001
From: Vinicius Reis <vinicius.reis@nextcloud.com>
Date: Mon, 6 Jun 2022 17:34:10 -0300
Subject: =?UTF-8?q?=E2=9C=A8=20(#2463):=20emit=20error=20when=20image=20lo?=
 =?UTF-8?q?ading=20fails?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
---
 src/nodes/ImageView.vue | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'src/nodes/ImageView.vue')

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({
-- 
cgit v1.2.3

