qHexWalker 0.0.1
Hexagonal Grid Pathfinding & Maze Visualization on Interactive Maps
Loading...
Searching...
No Matches
pathfindingErrors.h
Go to the documentation of this file.
1
12#ifndef Q_HEX_WALKER_PATHFINDING_ERRORS_H
13#define Q_HEX_WALKER_PATHFINDING_ERRORS_H
14
15#include <stdexcept>
16#include <string>
17
36
42inline std::string pathfindingErrorToString(const PathfindingError error) {
43 switch (error) {
45 return "No error";
47 return "Invalid H3 cell index";
49 return "Start and end points are identical";
51 return "Start cell is blocked";
53 return "End cell is blocked";
55 return "No path found between points";
57 return "Error converting between H3 resolutions";
59 return "Error getting cell coordinates";
61 return "Search exceeded maximum iterations";
63 return "Internal algorithm error";
64 default:
65 return "Unknown error";
66 }
67}
68
75class PathfindingException final : public std::runtime_error {
76public:
78 : std::runtime_error(pathfindingErrorToString(error)), errorCode_(error) {}
79
80 [[nodiscard("known error")]] PathfindingError errorCode() const noexcept { return errorCode_; }
81
82private:
84};
85
138#endif // Q_HEX_WALKER_PATHFINDING_ERRORS_H
Exception class for pathfinding errors.
PathfindingError errorCode() const noexcept
PathfindingError errorCode_
PathfindingException(const PathfindingError error)
PathfindingError
Error codes for pathfinding operations.
@ ConversionError
Error converting between H3 resolutions.
@ None
No error occurred.
@ BlockedEndCell
End cell is blocked by an obstacle.
@ InternalError
Internal algorithm error.
@ MaxIterations
Search exceeded maximum iteration limit.
@ BlockedStartCell
Start cell is blocked by an obstacle.
@ NoPathFound
No path exists between start and end (disconnected graph)
@ SameStartEnd
Start and end points are identical.
@ CoordinateError
Error getting cell coordinates.
@ InvalidCell
One or both cells are invalid (H3_NULL or failed isValidCell)
std::string pathfindingErrorToString(const PathfindingError error)
Converts PathfindingError to human-readable string.