fix Zabbix API error message
This commit is contained in:
4
dist/datasource-zabbix/datasource.js
vendored
4
dist/datasource-zabbix/datasource.js
vendored
@@ -582,13 +582,13 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
|||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
title: error.message,
|
title: error.message,
|
||||||
message: error.data
|
message: error.message
|
||||||
};
|
};
|
||||||
} else if (error.data && error.data.message) {
|
} else if (error.data && error.data.message) {
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "Connection failed",
|
title: "Connection failed",
|
||||||
message: error.data.message
|
message: "Connection failed: " + error.data.message
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
|||||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
12
dist/datasource-zabbix/zabbixAPICore.service.js
vendored
12
dist/datasource-zabbix/zabbixAPICore.service.js
vendored
@@ -100,8 +100,6 @@ System.register(['angular'], function (_export, _context) {
|
|||||||
|
|
||||||
// Success
|
// Success
|
||||||
return response.data.result;
|
return response.data.result;
|
||||||
}).catch(function () {
|
|
||||||
return Promise.reject(new ZabbixAPIError({ data: "Connection Error" }));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@@ -127,16 +125,16 @@ System.register(['angular'], function (_export, _context) {
|
|||||||
function ZabbixAPIError(error) {
|
function ZabbixAPIError(error) {
|
||||||
_classCallCheck(this, ZabbixAPIError);
|
_classCallCheck(this, ZabbixAPIError);
|
||||||
|
|
||||||
this.code = error.code;
|
this.code = error.code || null;
|
||||||
this.name = error.data;
|
this.name = error.message || "";
|
||||||
this.message = error.data;
|
this.data = error.data || "";
|
||||||
this.data = error.data;
|
this.message = "Zabbix API Error: " + this.name + " " + this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(ZabbixAPIError, [{
|
_createClass(ZabbixAPIError, [{
|
||||||
key: 'toString',
|
key: 'toString',
|
||||||
value: function toString() {
|
value: function toString() {
|
||||||
return this.name + ": " + this.message;
|
return this.name + " " + this.data;
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
4
dist/test/datasource-zabbix/datasource.js
vendored
4
dist/test/datasource-zabbix/datasource.js
vendored
@@ -466,13 +466,13 @@ var ZabbixAPIDatasource = function () {
|
|||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
title: error.message,
|
title: error.message,
|
||||||
message: error.data
|
message: error.message
|
||||||
};
|
};
|
||||||
} else if (error.data && error.data.message) {
|
} else if (error.data && error.data.message) {
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "Connection failed",
|
title: "Connection failed",
|
||||||
message: error.data.message
|
message: "Connection failed: " + error.data.message
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -83,8 +83,6 @@ var ZabbixAPICoreService = function () {
|
|||||||
|
|
||||||
// Success
|
// Success
|
||||||
return response.data.result;
|
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) {
|
function ZabbixAPIError(error) {
|
||||||
_classCallCheck(this, ZabbixAPIError);
|
_classCallCheck(this, ZabbixAPIError);
|
||||||
|
|
||||||
this.code = error.code;
|
this.code = error.code || null;
|
||||||
this.name = error.data;
|
this.name = error.message || "";
|
||||||
this.message = error.data;
|
this.data = error.data || "";
|
||||||
this.data = error.data;
|
this.message = "Zabbix API Error: " + this.name + " " + this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClass(ZabbixAPIError, [{
|
_createClass(ZabbixAPIError, [{
|
||||||
key: 'toString',
|
key: 'toString',
|
||||||
value: function toString() {
|
value: function toString() {
|
||||||
return this.name + ": " + this.message;
|
return this.name + " " + this.data;
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|||||||
@@ -378,13 +378,13 @@ class ZabbixAPIDatasource {
|
|||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
title: error.message,
|
title: error.message,
|
||||||
message: error.data
|
message: error.message
|
||||||
};
|
};
|
||||||
} else if (error.data && error.data.message) {
|
} else if (error.data && error.data.message) {
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "Connection failed",
|
title: "Connection failed",
|
||||||
message: error.data.message
|
message: "Connection failed: " + error.data.message
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class ZabbixAPICoreService {
|
|||||||
|
|
||||||
datasourceRequest(requestOptions) {
|
datasourceRequest(requestOptions) {
|
||||||
return this.backendSrv.datasourceRequest(requestOptions)
|
return this.backendSrv.datasourceRequest(requestOptions)
|
||||||
.then(response => {
|
.then((response) => {
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
return Promise.reject(new ZabbixAPIError({data: "General Error, no data"}));
|
return Promise.reject(new ZabbixAPIError({data: "General Error, no data"}));
|
||||||
} else if (response.data.error) {
|
} else if (response.data.error) {
|
||||||
@@ -64,9 +64,6 @@ class ZabbixAPICoreService {
|
|||||||
|
|
||||||
// Success
|
// Success
|
||||||
return response.data.result;
|
return response.data.result;
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
return Promise.reject(new ZabbixAPIError({data: "Connection Error"}));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,14 +91,14 @@ class ZabbixAPICoreService {
|
|||||||
// Define zabbix API exception type
|
// Define zabbix API exception type
|
||||||
export class ZabbixAPIError {
|
export class ZabbixAPIError {
|
||||||
constructor(error) {
|
constructor(error) {
|
||||||
this.code = error.code;
|
this.code = error.code || null;
|
||||||
this.name = error.data;
|
this.name = error.message || "";
|
||||||
this.message = error.data;
|
this.data = error.data || "";
|
||||||
this.data = error.data;
|
this.message = "Zabbix API Error: " + this.name + " " + this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
return this.name + ": " + this.message;
|
return this.name + " " + this.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user