Set up error handling for shortest path.