fabric8-analytics-dependency-editor-jyas
Version:
61 lines • 2.6 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { Http, RequestOptions, XHRBackend } from '@angular/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';
var HttpInterceptor = /** @class */ (function (_super) {
__extends(HttpInterceptor, _super);
function HttpInterceptor(backend, options, http) {
var _this = _super.call(this, backend, options) || this;
_this.http = http;
return _this;
}
HttpInterceptor.prototype.request = function (url, options) {
return _super.prototype.request.call(this, url, options)
.catch(this.handleError);
};
HttpInterceptor.prototype.handleError = function (error) {
console.log('Inside Interceptor', error);
var formError = {
status: error.status
};
// formError['message'] = HttpInterceptor.ERROR_HASH[error.status.toString()];
formError['message'] = HttpInterceptor.ERROR_HASH['GENERIC'];
return Observable.throw(formError);
};
HttpInterceptor.ERROR_HASH = {
'400': 'The request is not proper',
'401': 'Authentication failed - could not decode JWT token',
'403': 'No Permission to Access',
'404': 'The request is not proper',
'405': 'The method is not allowed for the requested URL',
'500': 'Server responded with error Retry again later',
'501': 'Server responded with error Retry again later',
'502': 'The server encountered a temporary error and could not complete your request',
'504': 'Gateway Timeout, try again later',
'GENERIC': 'There was a problem fetching results, please try again'
};
HttpInterceptor.decorators = [
{ type: Injectable },
];
/** @nocollapse */
HttpInterceptor.ctorParameters = function () { return [
{ type: XHRBackend, },
{ type: RequestOptions, },
{ type: Http, },
]; };
return HttpInterceptor;
}(Http));
export { HttpInterceptor };
//# sourceMappingURL=http-interceptor.js.map