refactor: replace asserts with eoException-based validation
This commit is contained in:
parent
5c858eeb2e
commit
f799857da9
2 changed files with 26 additions and 2 deletions
|
|
@ -48,7 +48,19 @@ public:
|
||||||
*/
|
*/
|
||||||
eoRanking(double _p = 2.0, double _e = 1.0) : pressure(_p), exponent(_e)
|
eoRanking(double _p = 2.0, double _e = 1.0) : pressure(_p), exponent(_e)
|
||||||
{
|
{
|
||||||
assert(1 < pressure and exponent <= 2);
|
if (pressure <= 1.0)
|
||||||
|
{
|
||||||
|
std::string msg = "eoRanking: pressure must be > 1.0";
|
||||||
|
eo::log << eo::errors << "ERROR: " << msg << std::endl;
|
||||||
|
throw eoException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exponent > 2.0)
|
||||||
|
{
|
||||||
|
std::string msg = "eoRanking: exponent must be <= 2.0";
|
||||||
|
eo::log << eo::errors << "ERROR: " << msg << std::endl;
|
||||||
|
throw eoException(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* helper function: finds index in _pop of _eo, an EOT * */
|
/* helper function: finds index in _pop of _eo, an EOT * */
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,19 @@ public:
|
||||||
*/
|
*/
|
||||||
eoRankingCached(double _p = 2.0, double _e = 1.0) : pressure(_p), exponent(_e), cached_pSize(0)
|
eoRankingCached(double _p = 2.0, double _e = 1.0) : pressure(_p), exponent(_e), cached_pSize(0)
|
||||||
{
|
{
|
||||||
assert(1 < pressure and exponent <= 2);
|
if (pressure <= 1.0)
|
||||||
|
{
|
||||||
|
std::string msg = "eoRankingCached: pressure must be > 1.0";
|
||||||
|
eo::log << eo::errors << "ERROR: " << msg << std::endl;
|
||||||
|
throw eoException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exponent > 2.0)
|
||||||
|
{
|
||||||
|
std::string msg = "eoRankingCached: exponent must be <= 2.0";
|
||||||
|
eo::log << eo::errors << "ERROR: " << msg << std::endl;
|
||||||
|
throw eoException(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue