added http error catch

This commit is contained in:
Janis Meister
2022-03-04 11:58:05 +01:00
parent e06cc3e8e3
commit 03f904b632

View File

@@ -3,6 +3,7 @@ import { EventEmitter } from '@angular/core';
import { PythonBackendService } from '../services/python-backend.service';
import { RouteResponse } from '../interfaces/routeResponse';
import { SearchResponse, SearchWay } from '../interfaces/searchResponse';
import { catchError, of } from 'rxjs';
@Component({
selector: 'app-search',
@@ -65,10 +66,15 @@ export class SearchComponent {
if(this.selectedSearchWayFrom && this.selectedSearchWayTo)
this.isSearching = true;
this.pythonBackendService.sendRouteQueryRequest(this.selectedSearchWayFrom.id.toString(), this.selectedSearchWayTo.id.toString())
.pipe(catchError(err =>{
console.error(err);
return of({nodes:[]});
}))
.subscribe(
(response: RouteResponse) => {
this.emitter.emit(response);
this.isSearching = false;
});
}
}