#include <cstdint>
#include <string>

class ErrorHandler
{
  private:
	uint8_t numErrors = 0;
	uint8_t critThresh = 0;
	uint32_t timeoutSec = 0;
	std::string id;
	uint64_t lastTickCount = 0;
	bool firstError = true;

  public:
	// TODO need to add a function pointer that allows other criticalThreshold functions to be
	// called
	ErrorHandler(std::string ID, uint8_t criticalThreshold, uint32_t timeoutSeconds) :
		critThresh(criticalThreshold), timeoutSec(timeoutSeconds)
	{
		id = "**Error ID: " + ID;
	}

	void cpfAssert(bool forceRecovery, std::string_view comment);
	void criticalErrorHandler();
	bool logError();
};
