Class FaultHandlers
Defined in File fault_handlers.hpp
Class Documentation
-
class FaultHandlers
Handlers for fault management REST API endpoints.
Provides handlers for:
GET /faults - List all faults (extension)
DELETE /faults - Clear all faults globally (extension)
GET /{entity-path}/faults - List faults for entity
GET /{entity-path}/faults/{code} - Get specific fault
DELETE /{entity-path}/faults/{code} - Clear fault
DELETE /{entity-path}/faults - Clear all faults for entity
Note: Snapshot data is inline in fault responses (environment_data). Rosbag downloads use the bulk-data endpoint pattern.
Public Functions
-
inline explicit FaultHandlers(HandlerContext &ctx)
Construct fault handlers with shared context.
- Parameters:
ctx – The shared handler context
-
void handle_list_all_faults(const httplib::Request &req, httplib::Response &res)
Handle GET /faults - list all faults.
-
void handle_list_faults(const httplib::Request &req, httplib::Response &res)
Handle GET /components/{component_id}/faults - list faults for component.
-
void handle_get_fault(const httplib::Request &req, httplib::Response &res)
Handle GET /components/{component_id}/faults/{fault_code} - get specific fault.
-
void handle_clear_fault(const httplib::Request &req, httplib::Response &res)
Handle DELETE /components/{component_id}/faults/{fault_code} - clear fault.
-
void handle_clear_all_faults(const httplib::Request &req, httplib::Response &res)
Handle DELETE /components/{component_id}/faults - clear all faults for entity.
-
void handle_clear_all_faults_global(const httplib::Request &req, httplib::Response &res)
Handle DELETE /faults - clear all faults globally (extension, not SOVD).
Accepts optional ?status= query parameter to filter which faults to clear.
Public Static Functions
-
static nlohmann::json build_sovd_fault_response(const ros2_medkit_msgs::msg::Fault &fault, const ros2_medkit_msgs::msg::EnvironmentData &env_data, const std::string &entity_path)
Build SOVD-compliant fault response with environment data.
Creates a response containing:
”item” with fault details and SOVD status object
”environment_data” with extended_data_records and snapshots
”x-medkit” extensions with occurrence_count, severity_label, etc.
- Parameters:
fault – The fault message from fault_manager
env_data – Environment data with snapshots
entity_path – Entity path for bulk_data_uri generation (e.g., “/apps/motor”)
- Returns:
SOVD-compliant JSON response