From 7ca16405dd827f79b0c9f49f3b44774ce3553a85 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 10 Oct 2017 15:53:29 +0200 Subject: Number exceptions for easy return code Signed-off-by: Szczepan Zalega --- include/DeviceCommunicationExceptions.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/DeviceCommunicationExceptions.h b/include/DeviceCommunicationExceptions.h index 2913975..4dbd35d 100644 --- a/include/DeviceCommunicationExceptions.h +++ b/include/DeviceCommunicationExceptions.h @@ -6,6 +6,7 @@ #include #include + class DeviceCommunicationException: public std::runtime_error { std::string message; @@ -14,6 +15,7 @@ public: DeviceCommunicationException(std::string _msg): std::runtime_error(_msg), message(_msg){ ++occurred; } + const uint8_t getType() const {return 1;}; // virtual const char* what() const throw() override { // return message.c_str(); // } @@ -24,21 +26,26 @@ public: class DeviceNotConnected: public DeviceCommunicationException { public: DeviceNotConnected(std::string msg) : DeviceCommunicationException(msg){} + const uint8_t getType(){return 2;}; + }; class DeviceSendingFailure: public DeviceCommunicationException { public: DeviceSendingFailure(std::string msg) : DeviceCommunicationException(msg){} + const uint8_t getType(){return 3;}; }; class DeviceReceivingFailure: public DeviceCommunicationException { public: DeviceReceivingFailure(std::string msg) : DeviceCommunicationException(msg){} + const uint8_t getType(){return 4;}; }; class InvalidCRCReceived: public DeviceReceivingFailure { public: InvalidCRCReceived(std::string msg) : DeviceReceivingFailure(msg){} + const uint8_t getType(){return 5;}; }; -- cgit v1.2.1