ADTF
error_handling_intf.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include <adtfucom3/adtf_ucom3.h>
9 
10 namespace adtf
11 {
12 namespace base
13 {
14 namespace elasto
15 {
16 
24 {
25  public:
26  ADTF_IID(IErrorHandling, "error_handling.elasto.services.adtf.iid");
27 
28  public:
32  enum class tAction: uint32_t
33  {
34  Ignore = 0,
35  Log,
36  Stop,
37  Shutdown,
38  Abort
39  };
40 
45  {
46  public:
47  ADTF_IID(IErrorHandler, "error_handler.error_handling.elasto.services.adtf.iid");
48 
49  public:
55  virtual void Handle(tResult oError) = 0;
56 
57  protected:
58  ~IErrorHandler() = default;
59  };
60 
61  public:
62 
71  virtual tResult CreateErrorHandler(const char* strErrorSource,
72  const char* strErrorCategory,
73  tAction eDefaultAction,
75 
76  protected:
77  ~IErrorHandling() = default;
78 };
79 
83 class cErrorHandler: public ucom::catwo::object<IErrorHandling::IErrorHandler>
84 {
85  public:
92  cErrorHandler(const char* strErrorSource,
93  const char* strErrorCategory,
94  IErrorHandling::tAction eAction);
95 
99  void Handle(tResult oError) override;
100 
105 
111 
115  const char* GetErrorSource() const;
116 
120  const char* GetErrorCategory() const;
121 
122  private:
124 };
125 
134  const char* strErrorCategory,
135  IErrorHandling::tAction eDefaultAction);
136 
144 void handle_error(const char* strErrorSource,
145  const char* strErrorCategory,
146  IErrorHandling::tAction eDefaultAction,
147  tResult oError);
148 
149 }
150 
151 namespace flash
152 {
153 
158 {
159  public:
163  inline cErrorChecker()
164  {}
172  inline cErrorChecker(const char* strErrorSource,
173  const char* strErrorCategory,
174  elasto::IErrorHandling::tAction eDefaultAction):
175  m_pErrorHandler(elasto::create_error_handler(strErrorSource,
176  strErrorCategory,
177  eDefaultAction))
178  {}
185  void Create(const char* strErrorSource,
186  const char* strErrorCategory,
187  elasto::IErrorHandling::tAction eDefaultAction)
188  {
189  m_pErrorHandler = elasto::create_error_handler(strErrorSource,
190  strErrorCategory,
191  eDefaultAction);
192  }
198  inline void Check(tResult oResult)
199  {
200  if (IS_FAILED(oResult) && m_pErrorHandler)
201  {
202  m_pErrorHandler->Handle(oResult);
203  }
204  }
205 
206  private:
208 };
209 
210 }
211 
212 using elasto::IErrorHandling;
213 using elasto::cErrorHandler;
216 using flash::cErrorChecker;
217 
218 }
219 }
Copyright © Audi Electronics Venture GmbH.
Interface for handling an error from a specific error source and error category.
virtual void Handle(tResult oError)=0
Call this to notify the error handling of an error that occured.
tAction
Predefined actions that are supported by the default error handler implementation.
@ Stop
log error and stop the session.
@ Shutdown
log error and shutdown ADTF.
@ Abort
abort and create a stack trace.
virtual tResult CreateErrorHandler(const char *strErrorSource, const char *strErrorCategory, tAction eDefaultAction, ucom::ant::iobject_ptr< IErrorHandler > &pHandler)=0
Creates a new error handler for the given source and category.
Base class for implementing error handlers.
const char * GetErrorCategory() const
IErrorHandling::tAction GetAction() const
cErrorHandler(const char *strErrorSource, const char *strErrorCategory, IErrorHandling::tAction eAction)
Constructs a new error handler.
const char * GetErrorSource() const
void Handle(tResult oError) override
Call this to notify the error handling of an error that occured.
void SetAction(IErrorHandling::tAction eAction)
Sets the current action in case an error occurs.
Error checker implementation for easy use of the error handler elasto::IErrorHandling::IErrorHandler.
void Check(tResult oResult)
Checks the result and handle sit at error handler.
cErrorChecker(const char *strErrorSource, const char *strErrorCategory, elasto::IErrorHandling::tAction eDefaultAction)
CTOR which creates a error handler for the given values.
void Create(const char *strErrorSource, const char *strErrorCategory, elasto::IErrorHandling::tAction eDefaultAction)
Creates a error handler for the given values.
Base class for every interface type within the uCOM.
Definition: object_intf.h:31
Base object pointer to realize binary compatible reference counting in interface methods.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Definition: object.h:379
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
ucom::ant::object_ptr< IErrorHandling::IErrorHandler > create_error_handler(const char *strErrorSource, const char *strErrorCategory, IErrorHandling::tAction eDefaultAction)
Creates a new error handler.
void handle_error(const char *strErrorSource, const char *strErrorCategory, IErrorHandling::tAction eDefaultAction, tResult oError)
Convenience method to report an error for short lived objects.
Namespace for entire ADTF SDK.