mirror of
https://github.com/DerTyp7/osm-routing-angular.git
synced 2025-10-30 04:47:09 +01:00
added http error catch
This commit is contained in:
@@ -3,6 +3,7 @@ import { EventEmitter } from '@angular/core';
|
|||||||
import { PythonBackendService } from '../services/python-backend.service';
|
import { PythonBackendService } from '../services/python-backend.service';
|
||||||
import { RouteResponse } from '../interfaces/routeResponse';
|
import { RouteResponse } from '../interfaces/routeResponse';
|
||||||
import { SearchResponse, SearchWay } from '../interfaces/searchResponse';
|
import { SearchResponse, SearchWay } from '../interfaces/searchResponse';
|
||||||
|
import { catchError, of } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-search',
|
selector: 'app-search',
|
||||||
@@ -65,10 +66,15 @@ export class SearchComponent {
|
|||||||
if(this.selectedSearchWayFrom && this.selectedSearchWayTo)
|
if(this.selectedSearchWayFrom && this.selectedSearchWayTo)
|
||||||
this.isSearching = true;
|
this.isSearching = true;
|
||||||
this.pythonBackendService.sendRouteQueryRequest(this.selectedSearchWayFrom.id.toString(), this.selectedSearchWayTo.id.toString())
|
this.pythonBackendService.sendRouteQueryRequest(this.selectedSearchWayFrom.id.toString(), this.selectedSearchWayTo.id.toString())
|
||||||
|
.pipe(catchError(err =>{
|
||||||
|
console.error(err);
|
||||||
|
return of({nodes:[]});
|
||||||
|
}))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(response: RouteResponse) => {
|
(response: RouteResponse) => {
|
||||||
this.emitter.emit(response);
|
this.emitter.emit(response);
|
||||||
this.isSearching = false;
|
this.isSearching = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user