FAST.Framework  1.0.0
FException.h
1 /******************************************************************************
2 **
3 ** FAST.Framework
4 **
5 ** Created: 2023-10-11
6 ** Author: Boris Fast
7 ** Mail: support@fast-framework.com
8 **
9 ******************************************************************************/
10 
11 #ifndef FEXCEPTION_H
12 #define FEXCEPTION_H
13 
14 #include <string>
15 
16 using namespace std;
17 
18 #include "FObject.h"
19 #include "FString.h"
20 
24 class FException : public FObject, public exception
25 {
26  public:
27  FException(const FString& message = "General exception")
28  : buffer(message) { }
29 
30  virtual ~FException() = default;
31 
32  virtual const FString& Message() const throw();
33 
34  const type_info& GetType() override;
35  FString GetName() const override;
36 
37  private:
38  const FString buffer;
39 };
40 
45 {
46  public:
47  FIllegalArgumentException(const FString& message = "Illegal argument exception")
48  : FException(message) { }
49 
50  const type_info& GetType() override;
51  FString GetName() const override;
52 };
53 
58 {
59  public:
60  FNullPointerException(const FString& message = "Null pointer exception")
61  : FException(message) { }
62 
63  const type_info& GetType() override;
64  FString GetName() const override;
65 };
66 
71 {
72  public:
73  FOutOfMemoryException(const FString& message = "Out of memory exception")
74  : FException(message) { }
75 
76  const type_info& GetType() override;
77  FString GetName() const override;
78 };
79 
80 #define EXCEPTION(message) FException(FString::Format("%s:%s:%d:%s", __FILE__, __FUNCTION__, __LINE__, message))
81 #define NULLPOINTEREXCEPTION(message) FNullPointerException(FString::Format("%s:%s:%d:%s", __FILE__, __FUNCTION__, __LINE__, message))
82 #define ILLEGALARGUMENTEXCEPTION(message) FIllegalArgumentException(FString::Format("%s:%s:%d:%s", __FILE__, __FUNCTION__, __LINE__, message))
83 #define OUTOFMEMORYEXCEPTION(message) FOutOfMemoryException(FString::Format("%s:%s:%d:%s", __FILE__, __FUNCTION__, __LINE__, message))
84 
85 #endif // FEXCEPTION_H
Definition: FException.h:25
FException(const FString &message="General exception")
Constructor exception object.
Definition: FException.h:27
virtual ~FException()=default
Destroys the exception object.
Definition: FException.h:45
FIllegalArgumentException(const FString &message="Illegal argument exception")
Constructor exception object.
Definition: FException.h:47
Definition: FException.h:58
FNullPointerException(const FString &message="Null pointer exception")
Constructor exception object.
Definition: FException.h:60
Definition: FObject.h:50
Definition: FException.h:71
FOutOfMemoryException(const FString &message="Out of memory exception")
Constructor exception object.
Definition: FException.h:73
Definition: FString.h:22