mirror of
https://github.com/allankoechke/soci.git
synced 2026-11-30 10:58:24 +00:00
Further simplify Oracle error handling code
Remove ugly get_error_details() function taking multiple output parameters and just create oracle_soci_error objects directly. As error.h has now become useless, remove it too.
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
//
|
||||
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
#include "error.h"
|
||||
#include "soci/statement.h"
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
@@ -15,7 +14,6 @@
|
||||
|
||||
using namespace soci;
|
||||
using namespace soci::details;
|
||||
using namespace soci::details::oracle;
|
||||
|
||||
oracle_blob_backend::oracle_blob_backend(oracle_session_backend &session)
|
||||
: session_(session), lobp_(nullptr), initialized_(false)
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
//
|
||||
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
#include "error.h"
|
||||
#include <limits>
|
||||
|
||||
using namespace soci;
|
||||
using namespace soci::details;
|
||||
using namespace soci::details::oracle;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -107,12 +105,6 @@ std::string do_get_error_details(sword res, OCIError *errhp, int& errNum)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void soci::details::oracle::get_error_details(sword res, OCIError *errhp,
|
||||
std::string &msg, int &errNum)
|
||||
{
|
||||
msg = do_get_error_details(res, errhp, errNum);
|
||||
}
|
||||
|
||||
oracle_soci_error::oracle_soci_error(sword res, OCIError *errhp)
|
||||
: soci_error(do_get_error_details(res, errhp, err_num_))
|
||||
{
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef SOCI_ORACLE_ERROR_H_INCLUDED
|
||||
#define SOCI_ORACLE_ERROR_H_INCLUDED
|
||||
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
|
||||
namespace soci
|
||||
{
|
||||
|
||||
namespace details
|
||||
{
|
||||
|
||||
namespace oracle
|
||||
{
|
||||
|
||||
void get_error_details(sword res, OCIError *errhp,
|
||||
std::string &msg, int &errNum);
|
||||
|
||||
} // namespace oracle
|
||||
|
||||
} // namespace details
|
||||
|
||||
} // namespace soci
|
||||
|
||||
#endif
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
#include "soci/callbacks.h"
|
||||
#include "soci/session.h"
|
||||
#include "error.h"
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@@ -16,7 +15,6 @@
|
||||
|
||||
using namespace soci;
|
||||
using namespace soci::details;
|
||||
using namespace soci::details::oracle;
|
||||
|
||||
namespace // unnamed
|
||||
{
|
||||
@@ -179,11 +177,12 @@ oracle_session_backend::oracle_session_backend(std::string const & serviceName,
|
||||
defaultSourceCharSetId, serviceName.c_str(), serviceName.size(), &nlsServiceLen);
|
||||
if (res != OCI_SUCCESS)
|
||||
{
|
||||
std::string msg;
|
||||
int errNum;
|
||||
get_error_details(res, errhp_, msg, errNum);
|
||||
// Note that we must create the exception object before calling
|
||||
// clean_up() as it invalidates the error handle used to get the
|
||||
// error details.
|
||||
oracle_soci_error err(res, errhp_);
|
||||
clean_up();
|
||||
throw oracle_soci_error(msg, errNum);
|
||||
throw err;
|
||||
}
|
||||
|
||||
res = OCINlsCharSetConvert(envhp_, errhp_,
|
||||
@@ -191,11 +190,9 @@ oracle_session_backend::oracle_session_backend(std::string const & serviceName,
|
||||
defaultSourceCharSetId, userName.c_str(), userName.size(), &nlsUserNameLen);
|
||||
if (res != OCI_SUCCESS)
|
||||
{
|
||||
std::string msg;
|
||||
int errNum;
|
||||
get_error_details(res, errhp_, msg, errNum);
|
||||
oracle_soci_error err(res, errhp_);
|
||||
clean_up();
|
||||
throw oracle_soci_error(msg, errNum);
|
||||
throw err;
|
||||
}
|
||||
|
||||
res = OCINlsCharSetConvert(envhp_, errhp_,
|
||||
@@ -203,11 +200,9 @@ oracle_session_backend::oracle_session_backend(std::string const & serviceName,
|
||||
defaultSourceCharSetId, password.c_str(), password.size(), &nlsPasswordLen);
|
||||
if (res != OCI_SUCCESS)
|
||||
{
|
||||
std::string msg;
|
||||
int errNum;
|
||||
get_error_details(res, errhp_, msg, errNum);
|
||||
oracle_soci_error err(res, errhp_);
|
||||
clean_up();
|
||||
throw oracle_soci_error(msg, errNum);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -251,11 +246,9 @@ oracle_session_backend::oracle_session_backend(std::string const & serviceName,
|
||||
static_cast<sb4>(nlsServiceLen), OCI_DEFAULT);
|
||||
if (res != OCI_SUCCESS)
|
||||
{
|
||||
std::string msg;
|
||||
int errNum;
|
||||
get_error_details(res, errhp_, msg, errNum);
|
||||
oracle_soci_error err(res, errhp_);
|
||||
clean_up();
|
||||
throw oracle_soci_error(msg, errNum);
|
||||
throw err;
|
||||
}
|
||||
|
||||
// register failover callback
|
||||
@@ -267,11 +260,9 @@ oracle_session_backend::oracle_session_backend(std::string const & serviceName,
|
||||
&fo, 0, static_cast<ub4>(OCI_ATTR_FOCBK), errhp_);
|
||||
if (res != OCI_SUCCESS)
|
||||
{
|
||||
std::string msg;
|
||||
int errNum;
|
||||
get_error_details(res, errhp_, msg, errNum);
|
||||
oracle_soci_error err(res, errhp_);
|
||||
clean_up();
|
||||
throw oracle_soci_error(msg, errNum);
|
||||
throw err;
|
||||
}
|
||||
|
||||
// create service context handle
|
||||
@@ -288,11 +279,9 @@ oracle_session_backend::oracle_session_backend(std::string const & serviceName,
|
||||
OCI_ATTR_SERVER, errhp_);
|
||||
if (res != OCI_SUCCESS)
|
||||
{
|
||||
std::string msg;
|
||||
int errNum;
|
||||
get_error_details(res, errhp_, msg, errNum);
|
||||
oracle_soci_error err(res, errhp_);
|
||||
clean_up();
|
||||
throw oracle_soci_error(msg, errNum);
|
||||
throw err;
|
||||
}
|
||||
|
||||
// allocate user session handle
|
||||
@@ -340,11 +329,9 @@ oracle_session_backend::oracle_session_backend(std::string const & serviceName,
|
||||
credentialType, mode);
|
||||
if (res != OCI_SUCCESS && res != OCI_SUCCESS_WITH_INFO)
|
||||
{
|
||||
std::string msg;
|
||||
int errNum;
|
||||
get_error_details(res, errhp_, msg, errNum);
|
||||
oracle_soci_error err(res, errhp_);
|
||||
clean_up();
|
||||
throw oracle_soci_error(msg, errNum);
|
||||
throw err;
|
||||
}
|
||||
|
||||
// set the session in the context handle
|
||||
@@ -352,11 +339,9 @@ oracle_session_backend::oracle_session_backend(std::string const & serviceName,
|
||||
0, OCI_ATTR_SESSION, errhp_);
|
||||
if (res != OCI_SUCCESS)
|
||||
{
|
||||
std::string msg;
|
||||
int errNum;
|
||||
get_error_details(res, errhp_, msg, errNum);
|
||||
oracle_soci_error err(res, errhp_);
|
||||
clean_up();
|
||||
throw oracle_soci_error(msg, errNum);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
#include "soci/blob.h"
|
||||
#include "clob.h"
|
||||
#include "error.h"
|
||||
#include "soci/rowid.h"
|
||||
#include "soci/statement.h"
|
||||
#include "soci/soci-platform.h"
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
#include "soci/blob.h"
|
||||
#include "clob.h"
|
||||
#include "error.h"
|
||||
#include "soci/rowid.h"
|
||||
#include "soci/statement.h"
|
||||
#include "soci/type-wrappers.h"
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
//
|
||||
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
#include "error.h"
|
||||
#include "handle.h"
|
||||
#include "soci/soci-backend.h"
|
||||
#include <cctype>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
#include "soci/statement.h"
|
||||
#include "clob.h"
|
||||
#include "error.h"
|
||||
#include "soci/soci-platform.h"
|
||||
#include "soci-mktime.h"
|
||||
#include "soci-vector-helpers.h"
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "soci/oracle/soci-oracle.h"
|
||||
#include "clob.h"
|
||||
#include "error.h"
|
||||
#include "soci/soci-platform.h"
|
||||
#include "soci-vector-helpers.h"
|
||||
#include <cctype>
|
||||
|
||||
Reference in New Issue
Block a user