bitfront-library
Version:
Angular CLI project with components and classes used by other Angular projects of the BIT foundation.
42 lines • 2.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomHttpInterceptor = void 0;
var core_1 = require("@angular/core");
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
var message_service_1 = require("../service/message.service");
var general_utils_service_1 = require("../service/general-utils.service");
var http_utils_service_1 = require("../service/http-utils.service");
var i0 = require("@angular/core");
var i1 = require("../service/message.service");
var i2 = require("../service/general-utils.service");
var CustomHttpInterceptor = /** @class */ (function () {
function CustomHttpInterceptor(messageService, generalUtils) {
this.messageService = messageService;
this.generalUtils = generalUtils;
}
CustomHttpInterceptor.prototype.intercept = function (request, next) {
var _this = this;
console.log("interceptando la llamada http");
this.generalUtils.startLoading();
return next.handle(request).pipe(operators_1.catchError(function (error) {
//this.store.dispatch(new AddGlobalError(error));
console.log("error que nos retorna el server", error);
var customError = http_utils_service_1.HttpUtilsService.getCustomError(error);
console.log("custom error", error);
_this.messageService.sendError(customError);
return rxjs_1.throwError(error);
}), operators_1.finalize(function () {
console.log("finalizando la llamada http");
_this.generalUtils.stopLoading();
}));
};
CustomHttpInterceptor.ɵfac = function CustomHttpInterceptor_Factory(t) { return new (t || CustomHttpInterceptor)(i0.ɵɵinject(i1.MessageService), i0.ɵɵinject(i2.GeneralUtils)); };
CustomHttpInterceptor.ɵprov = i0.ɵɵdefineInjectable({ token: CustomHttpInterceptor, factory: CustomHttpInterceptor.ɵfac });
return CustomHttpInterceptor;
}());
exports.CustomHttpInterceptor = CustomHttpInterceptor;
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CustomHttpInterceptor, [{
type: core_1.Injectable
}], function () { return [{ type: i1.MessageService }, { type: i2.GeneralUtils }]; }, null); })();
//# sourceMappingURL=custom-http-interceptor.js.map