00001 /* 00002 * Copyright (C) 2006-2007 Funambol, Inc. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License version 2 as 00006 * published by the Free Software Foundation. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR 00011 * PURPOSE. See the GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00016 * 02111-1307 USA 00017 */ 00018 00019 #ifndef INCL_CLIENT_EXC 00020 #define INCL_CLIENT_EXC 00021 00026 #include "base/fscapi.h" 00027 #include "base/errors.h" 00028 00029 #include <string> 00030 00031 00037 class ClientException { 00038 00039 private: 00040 00042 static ClientException* pinstance; 00043 00044 00046 char* errorMsg; 00048 WCHAR* werrorMsg; 00049 00051 DWORD errorCode; 00052 00054 bool fatal; 00055 00057 bool useMessageBox; 00058 00059 00060 protected: 00061 00063 ClientException(); 00064 00065 00066 public: 00067 00069 static ClientException* getInstance(); 00070 00072 ~ClientException(); 00073 00074 00076 void setExceptionData(const char* msg, 00077 DWORD code = NULL, 00078 bool fatalError = false, 00079 bool needDisplay = false); 00080 00081 00083 void clear(); 00084 00085 00087 const char* getErrorMsg(); 00088 const WCHAR* wgetErrorMsg(); 00089 const std::wstring wstrgetErrorMsg(); 00090 00091 DWORD getErrorCode(); 00092 bool isFatal(); 00093 bool needMessageBox(); 00094 00095 }; 00096 00097 00098 // ---------- Global functions ----------- 00099 00101 void throwClientException(const char* msg, 00102 DWORD code = NULL, 00103 bool fatalError = NULL, 00104 bool needDisplay = NULL); 00105 00107 void throwClientFatalException(const char* msg, 00108 DWORD code = NULL); 00109 00111 void manageClientException(ClientException* e); 00112 00115 #endif