From 401bac8c7730bfa8e3f7a6d97313f8510725cf1b Mon Sep 17 00:00:00 2001 From: Mirza Pandzo Date: Mon, 9 Dec 2019 15:01:31 +0100 Subject: [PATCH] Allow error message to be display in notice Allow error message to be returned from server side (and displayed in notice) together with success: 0 in the following form: ``` { "success": "0", "message": "File too large" } ``` --- src/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index f0c06168..afd1177a 100644 --- a/src/index.js +++ b/src/index.js @@ -327,9 +327,15 @@ export default class ImageTool { */ uploadingFailed(errorText) { console.log('Image Tool: uploading failed because of', errorText); - + + let errorMessage = 'Can not upload an image, try another.'; + let errorJson = JSON.parse(errorText); + if (errorJson.hasOwnProperty('message')) { + errorMessage = errorJson.message; + } + this.api.notifier.show({ - message: 'Can not upload an image, try another', + message: errorMessage, style: 'error' }); this.ui.hidePreloader();