Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
errorhandler.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file errorhandler.h
1 /*
2  This file is part of libodbc++.
3 
4  Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING. If not, write to
18  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  Boston, MA 02111-1307, USA.
20 */
21 
22 #ifndef __ODBCXX_ERRORHANDLER_H
23 #define __ODBCXX_ERRORHANDLER_H
24 
25 #include <RDBC/odbc++/setup.h>
26 #include <RDBC/odbc++/types.h>
27 #include <RDBC/odbc++/threads.h>
28 
29 namespace odbc {
30 
33  friend class DriverManager;
34  friend class DataStreamBuf;
35  friend class DataStream;
36  private:
37  // private data
38  struct PD;
39  PD* pd_;
40 
43 
44  //the maxumum number of warnings to contain at a time
45  enum {
46  MAX_WARNINGS=128
47  };
48 
49  protected:
50  void _postWarning(SQLWarning* w);
51 
52 
53 #if ODBCVER < 0x0300
54  void _checkErrorODBC2(SQLHENV henv,
55  SQLHDBC hdbc,
56  SQLHSTMT hstmt,
57  SQLRETURN r,
58  const ODBCXX_STRING& what);
59 #else
60 
61  void _checkErrorODBC3(SQLINTEGER handleType,
62  SQLHANDLE h,
63  SQLRETURN r, const ODBCXX_STRING& what);
64 #endif //ODBCVER < 0x0300
65 
66  void _checkStmtError(SQLHSTMT hstmt,
67  SQLRETURN r, const char* what="") {
68 
69  if(r==SQL_SUCCESS_WITH_INFO || r==SQL_ERROR) {
70 #if ODBCVER < 0x0300
71 
72  this->_checkErrorODBC2(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
73  r,ODBCXX_STRING_C(what));
74 #else
75 
76  this->_checkErrorODBC3(SQL_HANDLE_STMT,hstmt,r,ODBCXX_STRING_C(what));
77 
78 #endif
79  }
80  }
81 
82  void _checkConError(SQLHDBC hdbc, SQLRETURN r, const char* what="") {
83  if(r==SQL_SUCCESS_WITH_INFO || r==SQL_ERROR) {
84 #if ODBCVER < 0x0300
85 
86  this->_checkErrorODBC2(SQL_NULL_HENV, hdbc, SQL_NULL_HSTMT, r,
87  ODBCXX_STRING_C(what));
88 
89 #else
90 
91  this->_checkErrorODBC3(SQL_HANDLE_DBC, hdbc, r, ODBCXX_STRING_C(what));
92 
93 #endif
94  }
95  }
96 
97  void _checkEnvError(SQLHENV henv, SQLRETURN r, const char* what="") {
98  if(r==SQL_SUCCESS_WITH_INFO || r==SQL_ERROR) {
99 #if ODBCVER < 0x0300
100 
101  this->_checkErrorODBC2(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT,r,
102  ODBCXX_STRING_C(what));
103 
104 #else
105 
106  this->_checkErrorODBC3(SQL_HANDLE_ENV,henv,r,ODBCXX_STRING_C(what));
107 
108 #endif
109  }
110  }
111 
113  ErrorHandler(bool collectWarnings =true);
114 
115  public:
117  void clearWarnings();
118 
123  WarningList* getWarnings();
124 
126  virtual ~ErrorHandler();
127  };
128 
129 
130 }; // namespace odbc
131 
132 #endif