Clean up unexpected error handling in readwritesplit

By using the Error class, the code can be cleaned up and simplified.
This commit is contained in:
Markus Mäkelä
2019-06-14 10:06:38 +03:00
parent 5edfba6623
commit 7dde0edb54
3 changed files with 39 additions and 24 deletions

View File

@ -19,6 +19,7 @@
#include <maxscale/backend.hh>
#include <maxscale/modutil.hh>
#include <maxscale/response_stat.hh>
#include <maxscale/protocol/mysql.hh>
namespace maxscale
{
@ -87,6 +88,21 @@ public:
return rv;
}
bool is_unexpected_error() const
{
switch (m_code)
{
case ER_CONNECTION_KILLED:
case ER_SERVER_SHUTDOWN:
case ER_NORMAL_SHUTDOWN:
case ER_SHUTDOWN_COMPLETE:
return true;
default:
return false;
}
}
uint32_t code() const
{
return m_code;
@ -121,7 +137,7 @@ public:
}
private:
uint16_t m_code { 0 };
uint16_t m_code {0};
std::string m_sql_state;
std::string m_message;
};