mariadb/cxx/exception.cpp
Bradley C. Kuszmaul 95ba9175ef Add deadlock exception. Addresses #215.
git-svn-id: file:///svn/tokudb@1310 c7de825b-a66e-492c-adef-691d508d4ae1
2007-12-21 10:23:56 +00:00

49 lines
713 B
C++

#include <db.h>
#include <db_cxx.h>
DbException::~DbException() throw()
{
if (the_what!=0) {
delete [] the_what;
}
}
DbException::DbException(int err)
: the_err(err),
the_env(0)
{
FillTheWhat();
}
void DbException::FillTheWhat(void)
{
if (the_err!=0) {
the_what = strdup(db_strerror(the_err));
}
}
int DbException::get_errno() const
{
return the_err;
}
const char *DbException::what() const throw()
{
return the_what;
}
DbEnv *DbException::get_env() const
{
return the_env;
}
void DbException::set_env(DbEnv *new_env)
{
the_env = new_env;
}
DbDeadlockException::DbDeadlockException (DbEnv *env)
: DbException(DB_LOCK_DEADLOCK)
{
this->set_env(env);
}