zabbix-utils
Version:
TypeScript port of zabbix-utils - Python library for working with Zabbix API, Sender, and Getter protocols
71 lines • 2.96 kB
JavaScript
;
// zabbix_utils
//
// Copyright (C) 2001-2023 Zabbix SIA (Original Python library)
// Copyright (C) 2024-2025 Han Yong Lim <hanyong.lim@gmail.com> (TypeScript adaptation)
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProcessingError = exports.APINotSupported = exports.APIRequestError = exports.ModuleBaseException = void 0;
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
const common_1 = require("./common");
class ModuleBaseException extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
}
}
exports.ModuleBaseException = ModuleBaseException;
class APIRequestError extends ModuleBaseException {
constructor(apiError) {
if (typeof apiError === 'object' && apiError !== null) {
apiError.body = common_1.ModuleUtils.hidePrivate(apiError.body);
const message = `${apiError.message || ''} ${apiError.data || ''}`.trim();
super(message);
for (const [key, value] of Object.entries(apiError)) {
this[key] = value;
}
}
else {
super(String(apiError));
}
}
}
exports.APIRequestError = APIRequestError;
class APINotSupported extends ModuleBaseException {
/**
* Exception class when object/action is not supported by Zabbix API.
*
* @param message - Not supported object/action message.
* @param version - Current version of Zabbix API.
*/
constructor(message, version) {
if (version) {
message = `${message} is unsupported for Zabbix ${version} version`;
}
super(message);
}
}
exports.APINotSupported = APINotSupported;
class ProcessingError extends ModuleBaseException {
constructor(...args) {
super(args.map(arg => String(arg)).join(' '));
}
}
exports.ProcessingError = ProcessingError;
//# sourceMappingURL=exceptions.js.map