slightly better error messages when reading an enum value fails: also report the default used

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1464 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2010-08-02 23:05:05 +00:00
parent 0fc52a7952
commit 69ea39c64f
3 changed files with 25 additions and 16 deletions
+8 -2
View File
@@ -429,14 +429,20 @@ template <> void Reader::handle(FileName& f) {
// ----------------------------------------------------------------------------- : EnumReader
String EnumReader::notDoneErrorMessage() const {
if (!first) throw InternalError(_("No first value in EnumReader"));
return _ERROR_2_("unrecognized value", read, first);
}
void EnumReader::warnIfNotDone(Reader* errors_to) {
if (!done) {
// warning: unknown value
errors_to->warning(_ERROR_1_("unrecognized value", read));
errors_to->warning(notDoneErrorMessage());
}
}
void EnumReader::errorIfNotDone() {
if (!done) {
throw ParseError(_ERROR_1_("unrecognized value", read));
throw ParseError(notDoneErrorMessage());
}
}