Skip to content
Snippets Groups Projects
Commit c91690b4 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Removed the exceptions module because it was not used.

parent ec39ce24
No related branches found
No related tags found
1 merge request!1Sergi
#ifndef MODEL_CAR_EXCEPTIONS
#define MODEL_CAR_EXCEPTIONS
#include "exceptions.h"
#include <stdint.h>
/**
* \brief CModel_Car_Drivers_Base exception class
*
* This class implements the exceptions for the CModel_Car_Drivers_Base class.
*
* Similarly to other exception classes, it appends a class identifer
* string ("[CModel_Car_Drivers_Base] - ") to the error message in order to identify the
* class that generated the exception.
*
* The base class can be used to catch any exception thrown by the application
* or also, this class can be used in order to catch only exceptions generated
* by CModel_Car_Drivers_Base objects.
*
*/
class CModelCarException : public CException
{
public:
/**
* \brief Constructor
*
* The constructor calls the base class constructor to add the general
* exception identifier and then adds the class identifier string
* "[CModel_Car_Drivers_Base class]" and the supplied error message.
*
*
* \verbatim
* [Exception caught] - <where>
* [CModel_Car_Drivers_Base class] - <error message>
* \endverbatim
*
* \param where a null terminated string with the information about the name
* of the function, the source code filename and the line where
* the exception was generated. This string must be generated
* by the _HERE_ macro.
*
* \param error_msg a null terminated string that contains the error message.
* This string may have any valid character and there is no
* limit on its length.
*
*
*/
CModelCarException(const std::string& where, const std::string& error_msg);
/**
* \brief Constructor
*
* The constructor calls the base class constructor to add the general
* exception identifier and then adds the class identifier string
* "[CModel_Car_Drivers_Base class]", the supplied error message and the hexadecimal message received.
*
*
* \verbatim
* [Exception caught] - <where>
* [CModel_Car_Drivers_Base class] - <error message>
* [Serial message] - <serial_msg>
* \endverbatim
*
* \param where a null terminated string with the information about the name
* of the function, the source code filename and the line where
* the exception was generated. This string must be generated
* by the _HERE_ macro.
*
* \param error_msg a null terminated string that contains the error message.
* This string may have any valid character and there is no
* limit on its length.
*
* \param serial_msg Pointer to the message received by Serial port.
*
* \param msg_length Serial message length.
*
*/
CModelCarException(const std::string& where, const std::string& error_msg, const uint8_t *serial_msg, uint8_t msg_length);
};
#endif
#include "model_car_exceptions.h"
#include <string.h>
#include <stdio.h>
#include <iomanip>
const std::string model_car_driver_base_exception_msg="[CModel_Car_Drivers_Base class] - ";
CModelCarException::CModelCarException(const std::string& where, const std::string& error_msg):CException(where, model_car_driver_base_exception_msg)
{
this->error_msg+=error_msg;
}
CModelCarException::CModelCarException(const std::string& where, const std::string& error_msg, const uint8_t *serial_msg, uint8_t msg_length):CException(where, model_car_driver_base_exception_msg)
{
this->error_msg += error_msg;
std::ostringstream ss;
for (uint8_t i = 0; i < msg_length; i++)
ss << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int)serial_msg[i];
std::string msg_string(ss.str());
this->error_msg += "\n[Serial message] - ";
this->error_msg += msg_string;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment