Public Types | Public Member Functions | Public Attributes

MySqlPL::MSqlException Struct Reference

#include <mysqlpl.h>

Inheritance diagram for MySqlPL::MSqlException:
Inheritance graph
[legend]
Collaboration diagram for MySqlPL::MSqlException:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::exception super

Public Member Functions

 MSqlException (MYSQL *db, const char *file, int line)
 MSqlException (const char *msg, const char *file, int line)
 ~MSqlException () throw ()
virtual const char * what () const throw ()

Public Attributes

unsigned _sql_error_code
std::string _msg
std::string _last_sql
const char * _file
int _line

Detailed Description

Definition at line 104 of file mysqlpl.h.


Member Typedef Documentation

typedef std::exception MySqlPL::MSqlException::super

Definition at line 106 of file mysqlpl.h.


Constructor & Destructor Documentation

MySqlPL::MSqlException::MSqlException ( MYSQL *  db,
const char *  file,
int  line 
)

Definition at line 80 of file mysqlpl.cpp.

References _file, _line, _msg, and _sql_error_code.

{
    char buffer[2048];

    _sql_error_code = mysql_errno(db);
    const char* error_str = mysql_error(db);

#if MYSQLPL_PREP_STMT
    const char* state_str = mysql_sqlstate(db);
    sprintf(buffer, "MySQL error %u - SQLSTATE %s: %s", _sql_error_code, state_str, error_str);
    _sqlstate = state_str;
#else
    sprintf(buffer, "MySQL error %u: %s", _sql_error_code, error_str);
#endif

    _msg = _strdup((const char*)buffer);

    _file = file;
    _line = line;
}
MySqlPL::MSqlException::MSqlException ( const char *  msg,
const char *  file,
int  line 
)

Definition at line 145 of file mysqlpl.cpp.

References _file, _line, _msg, and _sql_error_code.

{
    _msg = _strdup(msg);
    _file = file;
    _line = line;
    _sql_error_code = 0;
}
MySqlPL::MSqlException::~MSqlException (  ) throw () [inline]

Definition at line 115 of file mysqlpl.h.

{}

Member Function Documentation

virtual const char* MySqlPL::MSqlException::what (  ) const throw () [inline, virtual]

Definition at line 117 of file mysqlpl.h.

References _msg.

{return _msg.c_str();}

Member Data Documentation

Definition at line 125 of file mysqlpl.h.

Referenced by MSqlException().

Definition at line 124 of file mysqlpl.h.

Definition at line 126 of file mysqlpl.h.

Referenced by MSqlException().

Definition at line 120 of file mysqlpl.h.

Referenced by MSqlException(), and what().

Definition at line 119 of file mysqlpl.h.

Referenced by MSqlException().


The documentation for this struct was generated from the following files: