Class FaultHandlers

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 nlohmann::json &fault_json, const nlohmann::json &env_data_json, const std::string &entity_path)

Build SOVD-compliant fault response from already-converted JSON.

Consumes the JSON shape returned by FaultManager::get_fault_with_env - fault_json is the per-fault flat representation (the FaultManager has already translated severity_label, status string, timestamps, etc.) and env_data_json carries extended_data_records plus a snapshots array with intermediate-shape entries (freeze_frame: type/name/data/topic/ message_type/captured_at_ns; rosbag: type/name/fault_code/size_bytes/ duration_sec/format).

Builds the final SOVD response containing:

  • ”item” with fault details and SOVD status object

  • ”environment_data” with extended_data_records and snapshots; for freeze_frame snapshots the handler parses “data”, extracts the primary value and packs the full payload into x-medkit; for rosbag snapshots the handler appends bulk_data_uri = entity_path + "/bulk-data/rosbags/" + fault_code.

  • ”x-medkit” extensions with occurrence_count, severity_label, etc.

Parameters:
  • fault_json – Per-fault JSON (as produced by the transport adapter).

  • env_data_json – Environment-data JSON (as produced by the transport).

  • entity_path – Entity path used to construct rosbag bulk_data_uri.

Returns:

SOVD-compliant JSON response