hunter-news-exceptions
Version:
Contains exceptions defition for Hunter News Social Network
45 lines • 1.69 kB
JavaScript
;
var os = require("os");
var BaseException = (function () {
function BaseException(message, innerException) {
this.message = message;
this.childExceptions = [];
if (innerException != null)
this.childExceptions.push(innerException);
}
/** Agrega una nueva linea para imprimir un error */
BaseException.prototype.newLine = function (index) {
var i = 0;
var prepend = os.EOL;
for (i = 0; i < index; i++) {
prepend += '\t';
}
prepend += 'innerException -> ';
return prepend;
};
/** Agrega un nuevo error hijo. Útil cuando se generan varios errores de igual jerarquía */
BaseException.prototype.pushChildException = function (exception) {
this.childExceptions.push(exception);
};
/** Deprecated. Será eliminado en las próximas versiones. No utilizar */
BaseException.prototype.print = function (index) {
return this.toString(index);
};
/** Retorna un texto con el error y los errores hijos */
BaseException.prototype.toString = function (index) {
var _this = this;
var message = this.message;
index = index || 0;
this.childExceptions.forEach(function (ex) {
if (ex.print != null && ex.print != 'undefined')
message += _this.newLine(index) + ex.print(index + 1);
else
message += _this.newLine(index) + ex.message;
});
index++;
return message;
};
return BaseException;
}());
exports.BaseException = BaseException;
//# sourceMappingURL=base.exception.js.map