Mobile API Reference  MicroStrategy 2019
ExceptionImpl.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : ExceptionImpl.h
3 // AUTHOR : Juan Pablo Muraira
4 // CREATION : 9/26/2001
5 // Copyright (C) MicroStrategy Incorporated 2001
6 // All Rights Reserved
7 //==============================================================================================
8 //
9 // ##### ###### ##### ##### ###### ##### #### ##### ###### #####
10 // # # # # # # # # # # # # # # #
11 // # # ##### # # # # ##### # # # # ##### # #
12 // # # # ##### ##### # # ###### # # # #
13 // # # # # # # # # # # # # # #
14 // ##### ###### # # # ###### ##### # # # ###### #####
15 //
16 #ifndef MBase_ExceptionImpl_h
17 #define MBase_ExceptionImpl_h
18 
19 #include "PDCHeader/PDCstring"
20 
21 #include "Asserte.h"
22 #include "../Base/LastError.h"
23 #include "../Base/UTFConverter.h"
24 #include "../Interfaces/BaseException.h"
25 
26 #if defined(GetMessage)
27 #error Please make sure that you include <winbase.h>/<windows.h> properly (via Common/PDCHeader)
28 #endif
29 
30 namespace MBase
31 {
75 // To compile ExecLibRubyBridge on HP-UX PA-RISC machine we have to clearly
76 // specify the parent class, not a template with default value. PA-RISC doesn't
77 // accept that. - hzhang 12/22/2005
78  template<class T = MBase::BaseException>
80 #ifndef __hpux
81  public T
82 #elif #cpu(parisc)
84 #else
85  public T
86 #endif
87  {
88  public:
89 #ifndef NO_WCHAR_SUPPORT
90  explicit ExceptionImpl(const WCHAR* ipcMessage) throw()
91  {
92  //SetDomainAndID(MBase::MESSAGE_DOMAIN_UNKNOWN, -1);
93  //SetMessage(ipcMessage != NULL ? ipcMessage : L"");
94  }
95 #endif
96 
97  explicit ExceptionImpl(const char* ipcUTF8Message) throw()
98  {
99  //SetDomainAndID(MBase::MESSAGE_DOMAIN_UNKNOWN, -1);
100  //SetMessage(MBase::UTF8ToWideChar(ipcUTF8Message != NULL ? ipcUTF8Message : "", true).c_str());
101  }
102 
120 #ifndef NO_WCHAR_SUPPORT
121  explicit ExceptionImpl(const WCHAR* ipcMessage, BaseException& irRelatedException) throw()
122  {
123  //SetDomainAndID(irRelatedException.GetDomain(), irRelatedException.GetID());
124  //Concatenate( ipcMessage, irRelatedException.GetMessage() );
125  }
126 #endif
127 
128  explicit ExceptionImpl(const char* ipcUTF8Message, BaseException& irRelatedException) throw()
129  {
130  //SetDomainAndID(irRelatedException.GetDomain(), irRelatedException.GetID());
131  //Concatenate( MBase::UTF8ToWideChar( ipcUTF8Message, true ).c_str(), irRelatedException.GetMessage() );
132  }
133 
145 #ifndef NO_WCHAR_SUPPORT
146  explicit ExceptionImpl(const WCHAR* ipcMessage, MBase::ErrorCode iErrorCode) throw()
147  {
148  //SetDomainAndID(MBase::MESSAGE_DOMAIN_UNKNOWN, iErrorCode);
149  //Concatenate(ipcMessage, MBase::GetSystemErrorDescription(iErrorCode).c_str());
150  }
151 #endif
152 
153  explicit ExceptionImpl(const char* ipUTF8Message, MBase::ErrorCode iErrorCode) throw()
154  {
155 #ifndef __ANDROID__
156  //SetDomainAndID(MBase::MESSAGE_DOMAIN_UNKNOWN, iErrorCode);
157  Concatenate(
158  MBase::UTF8ToWideChar( ipUTF8Message, true ).c_str(),
159  MBase::GetSystemErrorDescription(iErrorCode).c_str());
160 #endif
161  }
162 
164  const WCHAR* GetMessage() const throw()
165  {
166 #ifdef __ANDROID__
167  return "";
168 #else
169  return Message::GetMessage();
170 #endif
171  }
172 
175  {
176  return T::GetErrorCode();
177  }
178 
179  void SetErrorCode(MBase::ErrorCode iErrorCode) throw()
180  {
181  //SetDomainAndID(MBase::MESSAGE_DOMAIN_UNKNOWN, iErrorCode);
182  }
183 
184  private:
185 
186  void Concatenate( const WCHAR* ipcMessage, const WCHAR* ipcRelatedMessage ) throw()
187  {
188  try
189  {
190 #ifdef NO_WCHAR_SUPPORT
191  _ASSERTE( std::string( ipcMessage ).length() > 0 );
192  _ASSERTE( std::string( ipcRelatedMessage ).length() > 0 );
193 
194  std::string lMessage(ipcMessage);
195 #else
196  _ASSERTE( std::wstring( ipcMessage ).length() > 0 );
197  _ASSERTE( std::wstring( ipcRelatedMessage ).length() > 0 );
198 
199  std::wstring lMessage(ipcMessage);
200 #endif
201  // 2002-05-10 vovechkin
202  // The Pollux LogRouter handles multi-line messages correctly
203  lMessage += _T("\n");
204  lMessage += ipcRelatedMessage;
205 
206  //SetMessage(lMessage.c_str());
207  }
208  catch(...)
209  {
210  _ASSERT( false );
211  }
212  }
213  };
214 }
215 
216 #endif // MBase_ExceptionImpl_h
217 
wchar_t WCHAR
Definition: PDCwchar.h:23
ExceptionImpl(const char *ipcUTF8Message, BaseException &irRelatedException)
Definition: ExceptionImpl.h:128
#define _ASSERT(x)
Definition: Asserte.h:34
unsigned Int32 ErrorCode
Definition: LastError.h:31
#define _ASSERTE(x)
Definition: Asserte.h:40
DLL_BASE_EXIM ReturnWString UTF8ToWideChar(const char *ipUTF8, bool ibUseSubstitutionCharacter=false)
MBase::ErrorCode GetErrorCode() const
Definition: ExceptionImpl.h:174
ExceptionImpl(const WCHAR *ipcMessage)
Definition: ExceptionImpl.h:90
const WCHAR * GetMessage() const
Definition: ExceptionImpl.h:164
#define _T(x)
Definition: PDCtchar.h:94
DLL_BASE_EXIM ReturnWString GetSystemErrorDescription(ErrorCode iErrorCode)
ExceptionImpl(const char *ipUTF8Message, MBase::ErrorCode iErrorCode)
Definition: ExceptionImpl.h:153
Definition: Message.h:32
Definition: Allocator.h:47
void SetErrorCode(MBase::ErrorCode iErrorCode)
Definition: ExceptionImpl.h:179
const WCHAR * GetMessage() const
ExceptionImpl(const WCHAR *ipcMessage, BaseException &irRelatedException)
Definition: ExceptionImpl.h:121
ExceptionImpl(const char *ipcUTF8Message)
Definition: ExceptionImpl.h:97
Definition: ExceptionImpl.h:79
ExceptionImpl(const WCHAR *ipcMessage, MBase::ErrorCode iErrorCode)
Definition: ExceptionImpl.h:146