Fix handling unexpected errors.
This commit is contained in:
parent
f1140ec903
commit
88e6558da3
@ -164,8 +164,31 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
route_parameters.uturns, raw_route);
|
route_parameters.uturns, raw_route);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool no_route = INVALID_EDGE_WEIGHT == raw_route.shortest_path_length;
|
// we can only know this after the fact, different SCC ids still
|
||||||
|
// allow for connection in one direction.
|
||||||
|
if (raw_route.shortest_path_length == INVALID_EDGE_WEIGHT)
|
||||||
|
{
|
||||||
|
auto first_component_id = snapped_phantoms.front().component.id;
|
||||||
|
auto not_in_same_component =
|
||||||
|
std::any_of(snapped_phantoms.begin(), snapped_phantoms.end(),
|
||||||
|
[first_component_id](const PhantomNode &node)
|
||||||
|
{
|
||||||
|
return node.component.id != first_component_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (not_in_same_component)
|
||||||
|
{
|
||||||
|
json_result.values["status_message"] = "Impossible route between points";
|
||||||
|
return Status::EmptyResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
json_result.values["status_message"] = "No route found between points";
|
||||||
|
return Status::Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::unique_ptr<BaseDescriptor<DataFacadeT>> descriptor;
|
std::unique_ptr<BaseDescriptor<DataFacadeT>> descriptor;
|
||||||
switch (descriptor_table.get_id(route_parameters.output_format))
|
switch (descriptor_table.get_id(route_parameters.output_format))
|
||||||
{
|
{
|
||||||
@ -182,26 +205,6 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
|
|
||||||
descriptor->SetConfig(route_parameters);
|
descriptor->SetConfig(route_parameters);
|
||||||
descriptor->Run(raw_route, json_result);
|
descriptor->Run(raw_route, json_result);
|
||||||
|
|
||||||
// we can only know this after the fact, different SCC ids still
|
|
||||||
// allow for connection in one direction.
|
|
||||||
if (no_route)
|
|
||||||
{
|
|
||||||
auto first_component_id = snapped_phantoms.front().component.id;
|
|
||||||
auto not_in_same_component =
|
|
||||||
std::any_of(snapped_phantoms.begin(), snapped_phantoms.end(),
|
|
||||||
[first_component_id](const PhantomNode &node)
|
|
||||||
{
|
|
||||||
return node.component.id != first_component_id;
|
|
||||||
});
|
|
||||||
if (not_in_same_component)
|
|
||||||
{
|
|
||||||
json_result.values["status_message"] = "Impossible route between points";
|
|
||||||
return Status::EmptyResult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
json_result.values["status_message"] = "Found route between points";
|
json_result.values["status_message"] = "Found route between points";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user