Better error handling when unable to index an eval value
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-09-07 13:04:42 +02:00
parent 5c63b15ab7
commit 2e1bdcf3a4
2 changed files with 16 additions and 4 deletions

View File

@@ -61,16 +61,22 @@ namespace Porygon::Evaluation {
[[nodiscard]]
virtual const EvalValue* IndexValue(const EvalValue *val) const {
throw EvaluationException("Can't index this EvalValue");
std::stringstream err;
err << "Can't index this EvalValue: " << ToString() << " with key: " << val->ToString();
throw EvaluationException(err.str());
}
[[nodiscard]]
virtual const EvalValue* IndexValue(uint32_t hash) const {
throw EvaluationException("Can't index this EvalValue");
std::stringstream err;
err << "Can't index this EvalValue: " << ToString() << " with key hash: " << hash;
throw EvaluationException(err.str());
}
virtual void SetIndexValue(const EvalValue *key, const EvalValue* value) const {
throw EvaluationException("Can't index this EvalValue");
std::stringstream err;
err << "Can't index this EvalValue: " << ToString() << " with key: " << value->ToString();
throw EvaluationException(err.str());
}
[[nodiscard]]
@@ -92,6 +98,12 @@ namespace Porygon::Evaluation {
virtual EvalValue* Cast(shared_ptr<const ScriptType> castType) const{
throw new EvaluationException("Casting to invalid type.");
}
virtual std::string ToString() const{
std::stringstream s;
s << "Type: " << ScriptType::ToString(this->GetTypeClass());
return s.str();
}
};
class BooleanEvalValue : public EvalValue {