Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private handleError(response: HttpErrorResponse, originalUrl: string) {
let category: ErrorCategory;
let error: Ro.ErrorRepresentation | Ro.ErrorMap | string;
if (response.status === HttpStatusCode.InternalServerError) {
// this error should contain an error representatation
const errorRep = new Ro.ErrorRepresentation();
if (Ro.isErrorRepresentation(response.error)) {
errorRep.populate(response.error as Ro.IErrorRepresentation);
category = ErrorCategory.HttpServerError;
error = errorRep;
} else {
return this.handleInvalidResponse(ErrorCategory.HttpServerError);
}
} else if (response.status <= 0) {
// failed to connect
category = ErrorCategory.ClientError;
error = `Failed to connect to server: ${response.url || 'unknown'}`;
} else {
category = ErrorCategory.HttpClientError;
const message = (response.headers && response.headers.get('warning')) || 'Unknown client HTTP error';
if (response.status === HttpStatusCode.BadRequest ||