- improved error reporting for badly defined translations.

This needs to be handled by the caller for all use cases because the translation parser lacks the context to do a proper error report.
This commit is contained in:
Christoph Oelckers 2018-12-16 09:56:53 +01:00
commit a38e75db00
4 changed files with 148 additions and 136 deletions

View file

@ -729,7 +729,6 @@ DEFINE_PROPERTY(translation, L, Actor)
else
{
FRemapTable CurrentTranslation;
bool success = true;
CurrentTranslation.MakeIdentity();
for(int i = 1; i < PROP_PARM_COUNT; i++)
@ -744,14 +743,17 @@ DEFINE_PROPERTY(translation, L, Actor)
else
{
// parse all ranges to get a complete list of errors, if more than one range fails.
success |= CurrentTranslation.AddToTranslation(str);
try
{
CurrentTranslation.AddToTranslation(str);
}
catch (CRecoverableError &err)
{
bag.ScriptPosition.Message(MSG_WARNING, "Error in translation '%s':\n" TEXTCOLOR_CYAN "%s\n", str, err.GetMessage());
}
}
}
defaults->Translation = CurrentTranslation.StoreTranslation (TRANSLATION_Decorate);
if (!success)
{
bag.ScriptPosition.Message(MSG_WARNING, "Failed to parse translation");
}
}
}