SOCI Logo Get SOCI at SourceForge.net. Fast, secure and Free Open Source software downloads

error.cpp

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
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_ORACLE_SOURCE
00009 #include "soci-oracle.h"
00010 #include "error.h"
00011 #include <limits>
00012 #include <sstream>
00013 
00014 #ifdef _MSC_VER
00015 #pragma warning(disable:4355)
00016 #endif
00017 
00018 using namespace soci;
00019 using namespace soci::details;
00020 using namespace soci::details::oracle;
00021 
00022 oracle_soci_error::oracle_soci_error(std::string const & msg, int errNum)
00023     : soci_error(msg), err_num_(errNum)
00024 {
00025 }
00026 
00027 void soci::details::oracle::get_error_details(sword res, OCIError *errhp,
00028     std::string &msg, int &errNum)
00029 {
00030     text errbuf[512];
00031     sb4 errcode;
00032     errNum = 0;
00033 
00034     switch (res)
00035     {
00036     case OCI_NO_DATA:
00037         msg = "soci error: No data";
00038         break;
00039     case OCI_ERROR:
00040         OCIErrorGet(errhp, 1, 0, &errcode,
00041              errbuf, sizeof(errbuf), OCI_HTYPE_ERROR);
00042         msg = reinterpret_cast<char*>(errbuf);
00043         errNum = static_cast<int>(errcode);
00044         break;
00045     case OCI_INVALID_HANDLE:
00046         msg = "soci error: Invalid handle";
00047         break;
00048     default:
00049         msg = "soci error: Unknown error code";
00050     }
00051 }
00052 
00053 void soci::details::oracle::throw_oracle_soci_error(sword res, OCIError *errhp)
00054 {
00055     std::string msg;
00056     int errNum;
00057 
00058     get_error_details(res, errhp, msg, errNum);
00059     throw oracle_soci_error(msg, errNum);
00060 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
SourceForge Logo

Generated on Sun Oct 3 2010 17:42:16 for EXTRAS-SOCI by Doxygen 1.7.1