From 4eb9a9a0afab8e6e8e4d2928e82613a46cfb275f Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Wed, 7 Sep 2016 18:03:55 +1200 Subject: [PATCH] fix(image): support array in Messages.error --- app/shared/responseHandlers.js | 2 +- app/shared/services.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/shared/responseHandlers.js b/app/shared/responseHandlers.js index 95b7e9c92..16bdc248a 100644 --- a/app/shared/responseHandlers.js +++ b/app/shared/responseHandlers.js @@ -50,8 +50,8 @@ function genericHandler(data) { // This handler returns the original array on success or a newly created array containing // only one JSON object with the field message filled with the error message on failure. function deleteImageHandler(data) { - var response = []; // A string is returned on failure (Docker < 1.12) + var response = []; if (!isJSON(data)) { response.push({message: data}); } diff --git a/app/shared/services.js b/app/shared/services.js index 3d4c53352..b715ebc1d 100644 --- a/app/shared/services.js +++ b/app/shared/services.js @@ -207,12 +207,13 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize']) }); }, error: function (title, e, fallbackText) { - console.log(JSON.stringify(e, null, 4)); var msg = fallbackText; if (e.data && e.data.message) { msg = e.data.message; } else if (e.message) { msg = e.message; + } else if (e.data.length > 0 && e.data[0].message) { + msg = e.data[0].message; } $.gritter.add({ title: $sanitize(title),