23 #include "ocilibcpp/types.hpp"
27 inline Exception::Exception() noexcept
30 _pConnnection(
nullptr),
32 _type(static_cast<ExceptionType::Type>(0)),
39 inline Exception::Exception(
OCI_Error *err) noexcept
51 inline Exception::Exception(
const Exception& other) noexcept : Exception()
65 _pStatement = other._pStatement;
66 _pConnnection = other._pConnnection;
69 _errLib = other._errLib;
70 _errOracle = other._errOracle;
72 CopyWhat(other._what);
77 inline void Exception::CopyWhat(
const char* value) noexcept
90 const size_t len = strlen(value) + 1;
92 _what =
new (std::nothrow)
char[len];
95 memcpy(_what, value, len);
99 inline void Exception::SetWhat(
const otext* value) noexcept
102 #if defined(OCI_CHARSET_ANSI)
119 const size_t valueLenght = wcslen(value);
121 _what =
new (std::nothrow)
char[valueLenght + 1];
124 const otext* ptr = value;
127 mbrlen(
nullptr, 0, &mbs);
129 #if defined(_MSC_VER)
130 __pragma(warning(disable : 4996))
133 const size_t convLenght = wcsrtombs(_what, &ptr, valueLenght, &mbs);
135 #if defined(_MSC_VER)
136 __pragma(warning(
default: 4996))
139 const size_t whatLenght = (
static_cast<size_t>(-1) == convLenght) ? 0 : convLenght;
141 _what[whatLenght] = 0;
156 const char* str =
what();
165 #if defined(OCI_CHARSET_ANSI)
171 const size_t valueLenght = strlen(str);
173 message.resize(valueLenght);
175 const char* ptr = str;
178 mbrlen(
nullptr, 0, &mbs);
181 #if defined(_MSC_VER)
182 __pragma(warning(disable : 4996))
185 const size_t convLenght = mbsrtowcs(&message[0], &ptr, valueLenght, &mbs);
187 #if defined(_MSC_VER)
188 __pragma(warning(
default: 4996))
191 const size_t messLenght = (
static_cast<size_t>(-1) == convLenght) ? 0 : convLenght;
193 message.resize(messLenght);
222 return Connection(_pConnnection, Environment::GetEnvironmentHandle());
A connection or session with a specific database.
Exception class handling all OCILIB errors.
ostring GetMessage() const
Retrieve the error message.
const char * what() const noexcept override
Override the std::exception::what() method.
int GetOracleErrorCode() const
Return the Oracle error code.
unsigned int GetRow() const
Return the row index which caused an error during statement execution.
ExceptionType GetType() const
Return the Exception type.
virtual ~Exception() noexcept
Virtual destructor required for deriving from std::exception.
Connection GetConnection() const
Return the connection within the error occurred.
int GetInternalErrorCode() const
Return the OCILIB error code.
Statement GetStatement() const
Return the statement within the error occurred.
Object used for executing SQL or PL/SQL statement and returning the produced results.
struct OCI_Error OCI_Error
Encapsulates an Oracle or OCILIB exception.
OCI_SYM_PUBLIC int OCI_API OCI_ErrorGetInternalCode(OCI_Error *err)
Retrieve Internal Error code from error handle.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_ErrorGetType(OCI_Error *err)
Retrieve the type of error from error handle.
OCI_SYM_PUBLIC const otext *OCI_API OCI_ErrorGetString(OCI_Error *err)
Retrieve error message from error handle.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_ErrorGetRow(OCI_Error *err)
Return the row index which caused an error during statement execution.
OCI_SYM_PUBLIC OCI_Statement *OCI_API OCI_ErrorGetStatement(OCI_Error *err)
Retrieve statement handle within the error occurred.
OCI_SYM_PUBLIC int OCI_API OCI_ErrorGetOCICode(OCI_Error *err)
Retrieve Oracle Error code from error handle.
OCI_SYM_PUBLIC OCI_Connection *OCI_API OCI_ErrorGetConnection(OCI_Error *err)
Retrieve connection handle within the error occurred.
std::basic_string< otext, std::char_traits< otext >, std::allocator< otext > > ostring
string class wrapping the OCILIB otext * type and OTEXT() macros ( see Character sets )