Salome HOME
Empty AIS in the viewer: throw c++ exception (to be finalized, currently do nothing)
[modules/shaper.git] / src / Events / Events_Error.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * Events_Error.h
5  *
6  *  Created on: Apr 28, 2014
7  *      Author: sbh
8  */
9
10 #ifndef EVENTS_ERROR_H_
11 #define EVENTS_ERROR_H_
12
13 #include <Events.h>
14 #include <Events_Message.h>
15
16 #include <string>
17
18 /**\class Events_Error
19  * \ingroup EventsLoop
20  * \brief An error message event.
21  *
22  * Is generated by any algorithm or GUI of the application to inform the user about
23  * the problem. In GUI mode all such errors are collected in the message log window.
24  */
25 class Events_Error : public Events_Message
26 {
27   std::string myDescription;  ///< the description of the error
28
29 public:
30   /// default destructor   
31   EVENTS_EXPORT virtual ~Events_Error();
32
33   /// Identifier of this event (one for all errors)
34   EVENTS_EXPORT static Events_ID errorID();
35   /// Specific error string
36   EVENTS_EXPORT const char* description() const;
37   /// Allows to send an error quickly: it creates and sends the error object automatically
38   EVENTS_EXPORT static void send(const std::string& theDescription, const void* theSender = 0);
39
40   /// Throws a C++ exception about using an empty AIS object
41   /// \theDescription an exception information
42   EVENTS_EXPORT static void throwException(const std::string& theDescription);
43
44 protected:
45   /// Default constructor. Use "send" message for generation an error.
46   EVENTS_EXPORT Events_Error(const std::string& theDescription, const void* theSender = 0);
47 };
48
49 #endif /* EVENTS_ERROR_H_ */