void MySQL::error(sql::SQLException e, string file, int line, string func, string query) { if (e.getErrorCode() == 0) return ; ostringstream msg; msg << "ERROR: SQLException in " << file; msg << " (" << func << ") on line " << line << endl; msg << "ERROR: " << e.what(); msg << " (MySQL error code: " << e.getErrorCode(); msg << ", SQLState: " << e.getSQLState() << ")" << endl; msg << "ERROR: Query: " << query; upo::print_error(msg.str()); }
/** * Create an error message related to SQL Exception */ void MySQLConnWrapper::manageException(sql::SQLException& e){ if(e.getErrorCode() != 0){ std::string msg = "SQL Exception : " + static_cast<std::string>(e.what()); msg += " (MySQL error code : " + e.getErrorCode(); msg += ", SQLState : " + e.getSQLState() + " )\n"; std::cerr << msg << std::endl; } }
int newError(sql::SQLException &e) { int i = e.getErrorCode(); unsigned int j = 0; if(i == 1317) j = 1; if(i == 2003) j = 2; return j; }
db_error::db_error(const sql::SQLException &exc) : std::runtime_error(exc.what()), _error(exc.getErrorCode()) { }