fix Zabbix API error message

This commit is contained in:
Alexander Zobnin
2017-10-22 11:37:17 +03:00
parent 538589b99b
commit df64c190e2
8 changed files with 24 additions and 31 deletions

View File

@@ -466,13 +466,13 @@ var ZabbixAPIDatasource = function () {
return {
status: "error",
title: error.message,
message: error.data
message: error.message
};
} else if (error.data && error.data.message) {
return {
status: "error",
title: "Connection failed",
message: error.data.message
message: "Connection failed: " + error.data.message
};
} else {
return {

View File

@@ -83,8 +83,6 @@ var ZabbixAPICoreService = function () {
// Success
return response.data.result;
}).catch(function () {
return Promise.reject(new ZabbixAPIError({ data: "Connection Error" }));
});
}
@@ -125,16 +123,16 @@ var ZabbixAPIError = exports.ZabbixAPIError = function () {
function ZabbixAPIError(error) {
_classCallCheck(this, ZabbixAPIError);
this.code = error.code;
this.name = error.data;
this.message = error.data;
this.data = error.data;
this.code = error.code || null;
this.name = error.message || "";
this.data = error.data || "";
this.message = "Zabbix API Error: " + this.name + " " + this.data;
}
_createClass(ZabbixAPIError, [{
key: 'toString',
value: function toString() {
return this.name + ": " + this.message;
return this.name + " " + this.data;
}
}]);