Improve script exception error message.
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:
@@ -56,6 +56,9 @@ void StopBeforeAttack(ExecutingMove@ attack, bool& result) override{
|
||||
AS_CLASS(OnAfterHitsScript,
|
||||
"int value = 0; void OnAfterHits(ExecutingMove@ attack, Pokemon@ target) override { value++; } "
|
||||
"int GetValue() { return value; }"),
|
||||
AS_CLASS(throwScript,
|
||||
R"(void PreventAttack(ExecutingMove@ attack, bool& result) override{ throw("test exception"); })"),
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -271,4 +274,21 @@ TEST_CASE("Invoke OnAfterHits script function") {
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE("Handle script exceptions.") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "throwScript");
|
||||
bool b = false;
|
||||
bool hasThrown = false;
|
||||
try{
|
||||
script->PreventAttack(nullptr, &b);
|
||||
}
|
||||
catch (const CreatureException& e){
|
||||
hasThrown = true;
|
||||
REQUIRE(strcmp("Script exception in script 'throwScript', line 1. Message: 'test exception'.", e.what()) == 0);
|
||||
}
|
||||
REQUIRE(hasThrown);
|
||||
|
||||
delete script;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user