00001 // 00002 // Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, Rafal Bobrowski 00003 // Distributed under the Boost Software License, Version 1.0. 00004 // (See accompanying file LICENSE_1_0.txt or copy at 00005 // http://www.boost.org/LICENSE_1_0.txt) 00006 // 00007 00008 #define SOCI_FIREBIRD_SOURCE 00009 #include "soci-firebird.h" 00010 #include "error-firebird.h" 00011 00012 #include <cstdlib> 00013 #include <string> 00014 00015 namespace soci 00016 { 00017 00018 firebird_soci_error::firebird_soci_error(std::string const & msg, ISC_STATUS const * status) 00019 : soci_error(msg) 00020 { 00021 if (status != 0) 00022 { 00023 std::size_t i = 0; 00024 while (i < stat_size && status[i] != 0) 00025 { 00026 status_.push_back(status[i++]); 00027 } 00028 } 00029 } 00030 00031 namespace details 00032 { 00033 00034 namespace firebird 00035 { 00036 00037 void get_iscerror_details(ISC_STATUS * status_vector, std::string &msg) 00038 { 00039 char msg_buffer[SOCI_FIREBIRD_ERRMSG]; 00040 long *pvector = status_vector; 00041 00042 try 00043 { 00044 // fetching first error message 00045 isc_interprete(msg_buffer, &pvector); 00046 msg = msg_buffer; 00047 00048 // fetching next errors 00049 while (isc_interprete(msg_buffer, &pvector)) 00050 { 00051 msg += "\n"; 00052 msg += msg_buffer; 00053 } 00054 } 00055 catch (...) 00056 { 00057 throw firebird_soci_error("Exception catched while fetching error information"); 00058 } 00059 } 00060 00061 bool check_iscerror(ISC_STATUS const * status_vector, long errNum) 00062 { 00063 std::size_t i=0; 00064 while (status_vector[i] != 0) 00065 { 00066 if (status_vector[i] == 1 && status_vector[i+1] == errNum) 00067 { 00068 return true; 00069 } 00070 ++i; 00071 } 00072 00073 return false; 00074 } 00075 void throw_iscerror(ISC_STATUS * status_vector) 00076 { 00077 std::string msg; 00078 00079 get_iscerror_details(status_vector, msg); 00080 throw firebird_soci_error(msg, status_vector); 00081 } 00082 00083 } // namespace firebird 00084 00085 } // namespace details 00086 00087 } // namespace soci
Generated on Sun Oct 3 2010 17:42:16 for EXTRAS-SOCI by Doxygen 1.7.1