barracuda-client-api
Version:
API Client to connect to Barracuda Enterprise Service Bus
37 lines (36 loc) • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BarracudaError = void 0;
class BarracudaError extends Error {
constructor(msg, errorData) {
super(msg);
// Maintains proper stack trace for where our error was thrown (only available on V8)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, BarracudaError);
}
this.name = "BarracudaError";
// Custom debugging information
this.message = msg;
this._data = errorData;
}
get data() {
return this._data;
}
static isBarracudaError(ob) {
if (typeof ob !== "object") {
return false;
}
if (!BarracudaError.prototype.isPrototypeOf(ob)) {
return false;
}
return ob.name === BarracudaError.prototype.name;
}
static isBarracudaServerError(ob) {
var _a;
return BarracudaError.isBarracudaError(ob) && !!((_a = ob.data) === null || _a === void 0 ? void 0 : _a.isServerError);
}
toString() {
return super.toString() + " " + JSON.stringify(this.data);
}
}
exports.BarracudaError = BarracudaError;