Catch exception by reference.

Issue found by cppcheck.
This commit is contained in:
Mark de Wever 2011-02-27 15:20:01 +00:00
parent 57955fd392
commit 19b67d01e8

View File

@ -65,7 +65,7 @@ bool fuh::login(const std::string& name, const std::string& password, const std:
try {
hash = get_hash(name);
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not retrieve hash for user '" << name << "' :" << e.message << std::endl;
return false;
}
@ -94,7 +94,7 @@ std::string fuh::create_pepper(const std::string& name) {
try {
hash = get_hash(name);
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not retrieve hash for user '" << name << "' :" << e.message << std::endl;
return "";
}
@ -113,7 +113,7 @@ bool fuh::user_exists(const std::string& name) {
// Make a test query for this username
try {
return mysql_fetch_row(db_query("SELECT username FROM " + db_users_table_ + " WHERE UPPER(username)=UPPER('" + name + "')"));
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not execute test query for user '" << name << "' :" << e.message << std::endl;
// If the database is down just let all usernames log in
return false;
@ -126,7 +126,7 @@ bool fuh::user_is_moderator(const std::string& name) {
try {
return get_writable_detail_for_user(name, "user_is_moderator") == "1";
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not query user_is_moderator for user '" << name << "' :" << e.message << std::endl;
// If the database is down mark nobody as a mod
return false;
@ -139,7 +139,7 @@ void fuh::set_is_moderator(const std::string& name, const bool& is_moderator) {
try {
write_detail(name, "user_is_moderator", is_moderator ? "1" : "0");
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not set is_moderator for user '" << name << "' :" << e.message << std::endl;
}
}
@ -179,7 +179,7 @@ std::string fuh::get_valid_details() {
std::string fuh::get_hash(const std::string& user) {
try {
return get_detail_for_user(user, "user_password");
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not retrieve password for user '" << user << "' :" << e.message << std::endl;
return time_t(0);
}
@ -188,7 +188,7 @@ std::string fuh::get_hash(const std::string& user) {
std::string fuh::get_mail(const std::string& user) {
try {
return get_detail_for_user(user, "user_email");
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not retrieve email for user '" << user << "' :" << e.message << std::endl;
return time_t(0);
}
@ -198,7 +198,7 @@ time_t fuh::get_lastlogin(const std::string& user) {
try {
int time_int = atoi(get_writable_detail_for_user(user, "user_lastvisit").c_str());
return time_t(time_int);
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not retrieve last visit for user '" << user << "' :" << e.message << std::endl;
return time_t(0);
}
@ -208,7 +208,7 @@ time_t fuh::get_registrationdate(const std::string& user) {
try {
int time_int = atoi(get_detail_for_user(user, "user_regdate").c_str());
return time_t(time_int);
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not retrieve registration date for user '" << user << "' :" << e.message << std::endl;
return time_t(0);
}
@ -221,7 +221,7 @@ void fuh::set_lastlogin(const std::string& user, const time_t& lastlogin) {
try {
write_detail(user, "user_lastvisit", ss.str());
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not set last visit for user '" << user << "' :" << e.message << std::endl;
}
}
@ -261,7 +261,7 @@ void fuh::write_detail(const std::string& name, const std::string& detail, const
db_query("INSERT INTO " + db_extra_table_ + " VALUES('" + name + "','" + value + "','0')");
}
db_query("UPDATE " + db_extra_table_ + " SET " + detail + "='" + value + "' WHERE UPPER(username)=UPPER('" + name + "')");
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not set detail for user '" << name << "': " << e.message << std::endl;
}
}
@ -271,7 +271,7 @@ bool fuh::extra_row_exists(const std::string& name) {
// Make a test query for this username
try {
return mysql_fetch_row(db_query("SELECT username FROM " + db_extra_table_ + " WHERE UPPER(username)=UPPER('" + name + "')"));
} catch (error e) {
} catch (error& e) {
ERR_UH << "Could not execute test query for user '" << name << "' :" << e.message << std::endl;
return false;
}