Further work on better exceptions.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -25,9 +25,7 @@ namespace CreatureLib::Library {
|
||||
inline EffectParameterType GetType() const noexcept { return _type; }
|
||||
bool AsBool() const {
|
||||
if (_type != EffectParameterType::Bool) {
|
||||
std::stringstream ss;
|
||||
ss << "Cast effect parameter to bool, but was " << EffectParameterTypeHelper::ToString(_type);
|
||||
throw CreatureException(ss.str());
|
||||
THROW_CREATURE("Cast effect parameter to bool, but was " << EffectParameterTypeHelper::ToString(_type));
|
||||
}
|
||||
return std::get<bool>(_value);
|
||||
}
|
||||
@@ -36,9 +34,7 @@ namespace CreatureLib::Library {
|
||||
if (_type == EffectParameterType::Float) {
|
||||
return static_cast<int64_t>(std::get<float>(_value));
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss << "Cast effect parameter to int, but was " << EffectParameterTypeHelper::ToString(_type);
|
||||
throw CreatureException(ss.str());
|
||||
THROW_CREATURE("Cast effect parameter to int, but was " << EffectParameterTypeHelper::ToString(_type));
|
||||
}
|
||||
return std::get<int64_t>(_value);
|
||||
}
|
||||
@@ -47,17 +43,15 @@ namespace CreatureLib::Library {
|
||||
if (_type == EffectParameterType::Int) {
|
||||
return static_cast<float>(std::get<int64_t>(_value));
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss << "Cast effect parameter to float, but was " << EffectParameterTypeHelper::ToString(_type);
|
||||
throw CreatureException(ss.str());
|
||||
THROW_CREATURE("Cast effect parameter to float, but was "
|
||||
<< EffectParameterTypeHelper::ToString(_type));
|
||||
}
|
||||
return std::get<float>(_value);
|
||||
}
|
||||
const ArbUt::StringView& AsString() const {
|
||||
if (_type != EffectParameterType::String) {
|
||||
std::stringstream ss;
|
||||
ss << "Cast effect parameter to string, but was " << EffectParameterTypeHelper::ToString(_type);
|
||||
throw CreatureException(ss.str());
|
||||
THROW_CREATURE("Cast effect parameter to string, but was "
|
||||
<< EffectParameterTypeHelper::ToString(_type));
|
||||
}
|
||||
return std::get<ArbUt::StringView>(_value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user