From cb7e6c9cad7b0c8c3460ff5f3a71888b2813c288 Mon Sep 17 00:00:00 2001 From: Theodoros Katzalis <thodkatz@gmail.com> Date: Sun, 17 Mar 2019 17:23:51 +0200 Subject: [PATCH] Use a more suitable error message --- inc/ErrorHandler.hpp | 5 +++++ src/Helpers/TimeAndDate.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/inc/ErrorHandler.hpp b/inc/ErrorHandler.hpp index adffdc13..bd89fd33 100644 --- a/inc/ErrorHandler.hpp +++ b/inc/ErrorHandler.hpp @@ -56,6 +56,11 @@ public: * An error in the header of a packet makes it unable to be parsed */ UnacceptablePacket = 5, + + /** + * A date that isn't valid according to Gregorian calendar (the well-known civil calendar) + */ + InvalidDate = 6, }; /** diff --git a/src/Helpers/TimeAndDate.cpp b/src/Helpers/TimeAndDate.cpp index 2fbf5b85..59b604a6 100644 --- a/src/Helpers/TimeAndDate.cpp +++ b/src/Helpers/TimeAndDate.cpp @@ -16,12 +16,12 @@ TimeAndDate::TimeAndDate(uint16_t year, uint8_t month, uint8_t day, uint8_t hour // check if the parameters makes sense // @todo change the condition of the assertion for the \p year - assertI(2019 <= year < 2025, ErrorHandler::InternalErrorType::UnknownInternalError); - assertI(1 <= month <= 12, ErrorHandler::InternalErrorType::UnknownInternalError); - assertI(1 <= day <= 31, ErrorHandler::InternalErrorType::UnknownInternalError); - assertI(0 <= hour <= 24, ErrorHandler::InternalErrorType::UnknownInternalError); - assertI(0 <= minute <= 60, ErrorHandler::InternalErrorType::UnknownInternalError); - assertI(0 <= second <= 60, ErrorHandler::InternalErrorType::UnknownInternalError); + assertI(2019 <= year < 2025, ErrorHandler::InternalErrorType::InvalidDate); + assertI(1 <= month <= 12, ErrorHandler::InternalErrorType::InvalidDate); + assertI(1 <= day <= 31, ErrorHandler::InternalErrorType::InvalidDate); + assertI(0 <= hour <= 24, ErrorHandler::InternalErrorType::InvalidDate); + assertI(0 <= minute <= 60, ErrorHandler::InternalErrorType::InvalidDate); + assertI(0 <= second <= 60, ErrorHandler::InternalErrorType::InvalidDate); this->year = year; this->month = month; -- GitLab