summaryrefslogtreecommitdiffstats
path: root/src/modules/UserBackendMysql
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/UserBackendMysql')
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.cpp20
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.h6
2 files changed, 13 insertions, 13 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp
index 139a416..9b960fd 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp
@@ -132,7 +132,7 @@ void UserBackendMysql::configFinished() {
}
-boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() {
+boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() throw(Net::Exception) {
Net::ThreadManager::get()->detach();
mysql_ping(mysql);
@@ -140,8 +140,8 @@ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::
mysql_real_query(mysql, queryListUsers.c_str(), queryListUsers.length());
MYSQL_RES *result = mysql_use_result(mysql);
- if(mysql_num_fields(result) < 4)
- return boost::shared_ptr<std::map<unsigned long, Common::UserInfo> >(); // TODO Error
+ if(!result || mysql_num_fields(result) < 4)
+ throw Net::Exception(Net::Exception::NOT_AVAILABLE);
boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > users(new std::map<unsigned long, Common::UserInfo>());
@@ -157,7 +157,7 @@ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::
return users;
}
-boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) {
+boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) throw(Net::Exception) {
Net::ThreadManager::get()->detach();
mysql_ping(mysql);
@@ -174,8 +174,8 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long
mysql_real_query(mysql, query.c_str(), query.length());
MYSQL_RES *result = mysql_use_result(mysql);
- if(mysql_num_fields(result) < 4)
- return boost::shared_ptr<Common::UserInfo>(); // TODO Error
+ if(!result || mysql_num_fields(result) < 4)
+ throw Net::Exception(Net::Exception::NOT_AVAILABLE);
MYSQL_ROW row = mysql_fetch_row(result);
@@ -190,10 +190,10 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long
return user;
}
- return boost::shared_ptr<Common::UserInfo>();
+ throw Net::Exception(Net::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() {
+boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() throw(Net::Exception) {
Net::ThreadManager::get()->detach();
mysql_ping(mysql);
@@ -201,8 +201,8 @@ boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql:
mysql_real_query(mysql, queryListGroups.c_str(), queryListGroups.length());
MYSQL_RES *result = mysql_use_result(mysql);
- if(mysql_num_fields(result) < 2)
- return boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> >(); // TODO Error
+ if(!result || mysql_num_fields(result) < 2)
+ throw Net::Exception(Net::Exception::NOT_AVAILABLE);
boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > groups(new std::map<unsigned long, Common::GroupInfo>());
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.h b/src/modules/UserBackendMysql/UserBackendMysql.h
index 8a75a6b..1bf0f2b 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.h
+++ b/src/modules/UserBackendMysql/UserBackendMysql.h
@@ -50,10 +50,10 @@ class UserBackendMysql : public Server::UserBackend, private Common::Configurabl
virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool);
virtual void configFinished();
- virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList();
- virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid);
+ virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Net::Exception);
+ virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid) throw(Net::Exception);
- virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList();
+ virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Net::Exception);
public:
virtual ~UserBackendMysql() {