mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
codership/wsrep-lib#107 Replace exceptions with assertions
Replaced exceptions thrown on debug level sanity checks with assertions to be more graceful with release builds.
This commit is contained in:
@ -75,11 +75,10 @@ void wsrep::client_state::override_error(enum wsrep::client_error error,
|
|||||||
enum wsrep::provider::status status)
|
enum wsrep::provider::status status)
|
||||||
{
|
{
|
||||||
assert(wsrep::this_thread::get_id() == owning_thread_id_);
|
assert(wsrep::this_thread::get_id() == owning_thread_id_);
|
||||||
if (current_error_ != wsrep::e_success &&
|
// Error state should not be cleared with success code without
|
||||||
error == wsrep::e_success)
|
// explicit reset_error() call.
|
||||||
{
|
assert(current_error_ == wsrep::e_success ||
|
||||||
throw wsrep::runtime_error("Overriding error with success");
|
error != wsrep::e_success);
|
||||||
}
|
|
||||||
current_error_ = error;
|
current_error_ = error;
|
||||||
current_error_status_ = status;
|
current_error_status_ = status;
|
||||||
}
|
}
|
||||||
@ -494,21 +493,18 @@ void wsrep::client_state::state(
|
|||||||
{ 0, 1, 0, 0, 0}, /* result */
|
{ 0, 1, 0, 0, 0}, /* result */
|
||||||
{ 1, 0, 0, 0, 0} /* quit */
|
{ 1, 0, 0, 0, 0} /* quit */
|
||||||
};
|
};
|
||||||
if (allowed[state_][state])
|
if (!allowed[state_][state])
|
||||||
{
|
{
|
||||||
state_hist_.push_back(state_);
|
wsrep::log_debug() << "client_state: Unallowed state transition: "
|
||||||
state_ = state;
|
<< state_ << " -> " << state;
|
||||||
if (state_hist_.size() > 10)
|
assert(0);
|
||||||
{
|
|
||||||
state_hist_.erase(state_hist_.begin());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
state_hist_.push_back(state_);
|
||||||
|
state_ = state;
|
||||||
|
if (state_hist_.size() > 10)
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
state_hist_.erase(state_hist_.begin());
|
||||||
os << "client_state: Unallowed state transition: "
|
|
||||||
<< state_ << " -> " << state;
|
|
||||||
throw wsrep::runtime_error(os.str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,16 +520,11 @@ void wsrep::client_state::mode(
|
|||||||
{ 1, 1, 0, 0 }, /* toi */
|
{ 1, 1, 0, 0 }, /* toi */
|
||||||
{ 1, 0, 0, 0 } /* rsu */
|
{ 1, 0, 0, 0 } /* rsu */
|
||||||
};
|
};
|
||||||
if (allowed[mode_][mode])
|
if (!allowed[mode_][mode])
|
||||||
{
|
{
|
||||||
mode_ = mode;
|
wsrep::log_debug() << "client_state: Unallowed mode transition: "
|
||||||
|
<< mode_ << " -> " << mode;
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
else
|
mode_ = mode;
|
||||||
{
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "client_state: Unallowed mode transition: "
|
|
||||||
<< mode_ << " -> " << mode;
|
|
||||||
throw wsrep::runtime_error(os.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user