better error handling
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m39s
Run linting on the backend code / Build (pull_request) Successful in 34s
Run testing on the backend code / Build (pull_request) Failing after 3m3s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 24s

This commit is contained in:
Helldragon67 2025-01-27 18:39:10 +01:00
parent d6f723bee1
commit f64e60ddf6
2 changed files with 7 additions and 1 deletions

View File

@ -92,6 +92,9 @@ def new_trip(preferences: Preferences,
preferences = preferences
)
if len(landmarks) == 0 :
raise HTTPException(status_code=500, detail=f"No landmarks were found.")
# insert start and finish to the landmarks list
landmarks_short.insert(0, start_landmark)
landmarks_short.append(end_landmark)
@ -115,6 +118,9 @@ def new_trip(preferences: Preferences,
refined_tour = refiner.refine_optimization(landmarks, base_tour,
preferences.max_time_minute,
preferences.detour_tolerance_minute)
except TimeoutError as te :
logger.error(f'Refiner failed : {str(te)} Using base tour.')
refined_tour = base_tour
except Exception as exc :
raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {str(exc)}") from exc

View File

@ -588,7 +588,7 @@ class Optimizer:
circles = self.is_connected(solution)
i = 0
timeout = 40
timeout = 15
while circles is not None :
i += 1
if i == timeout :