CFx SDK Documentation  2023 SP0
daiErrorHandlerManager.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2019, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Open Design Alliance software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Open Design Alliance Copyright (C) 2002-2019 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 //
24 //How to use it:
25 //try
26 //{
27 //}
28 //catch(const someYourException& )
29 //{
30 // here should placed a code to catch your own excetions or maybe standard exception.
31 //}
32 //catch(...)
33 //{
34 // daiErrorHandlerManager::catchFunction();
35 //}
36 // Insert this part of code to places where you want use a standard exceptions handling .
37 
38 #ifndef _DAI_CATCH_H_
39 #define _DAI_CATCH_H_
40 
41 #include "OdaCommon.h"
42 #include "OdPlatformSettings.h"
43 #include "daiBuildOptions.h"
44 
45 #define STL_USING_STACK
46 #define STL_USING_VECTOR
47 #define STL_USING_ALGORITHM
48 #include "OdaSTL.h"
49 #include "OdError.h"
50 
51 #include "daiError/daiErrorId.h"
52 #include "SharedPtr.h"
53 
54 namespace OdDAI {
55 
56 #if defined(_MSC_VER)
57 #pragma warning(push)
58 #pragma warning(disable:4150)
59 #endif
60 
61  class BaseException;
62 
63  class daiErrorHandlerBase;
65 
67  {
68  public:
69  static void catchFunction();
70  static void log(daiErrorId minor, const char* errorDescription = 0, const char* functionId = 0);
71 
73 
74  static bool addHandler(const daiErrorHandlerPtr& handlerToAdd);
75  static bool removeHandler(const daiErrorHandlerPtr& handlerToDelete);
76 
77  protected:
78  void processOdError(const OdError& odError);
80 
81  void processError(daiErrorId minor, const char* errorDescription = 0, const char* functionId = 0);
83 
84  private:
87 
88  private:
89  class ExceptionDataProvider;
90 
91  friend class Session;
92  void resetSessionHandler(const daiErrorHandlerPtr& eventManagerHandler);
93 
94  daiErrorHandlerPtr m_sessionHandler;
95  std::vector<daiErrorHandlerPtr> m_handlersCollection;
96  std::stack<daiErrorId> m_errorStateCollection;
97  };
98 
99 #if defined(_MSC_VER)
100 #pragma warning(pop)
101 #endif
102 }
103 #endif
static bool removeHandler(const daiErrorHandlerPtr &handlerToDelete)
static daiErrorHandlerManager & instance()
static daiErrorId errorQuery()
static void log(daiErrorId minor, const char *errorDescription=0, const char *functionId=0)
void processOdError(const OdError &odError)
void processError(daiErrorId minor, const char *errorDescription=0, const char *functionId=0)
static bool addHandler(const daiErrorHandlerPtr &handlerToAdd)
#define DAI_EXPORT
unsigned int daiErrorId
Definition: daiErrorId.h:90
OdSharedPtr< daiErrorHandlerBase > daiErrorHandlerPtr