Op 1-4-2013 6:07, Scott Kostyshak schreef:
On Sat, Mar 30, 2013 at 10:02 AM, Vincent van Ravesteijn <v...@lyx.org> wrote:
Op 30-3-2013 6:08, Scott Kostyshak schreef:
The following command now throws an error:
lyx -dbg doesNotExist
NOTE: THIS PATCH IS INCOMPLETE. I think I have the right condition
for detecting the error, but I don't know what to do with it.
I see two ways of throwing an error:
(1) create a new enum value for Type, THROWERROR, which
LyX.cpp::parse_dbg() would test for on return and, if true,
it would handle the error message and exit
(2) from LyX.cpp::parse_dbg(), test lowercase(arg) to make sure it is not
NONE (or 0).
Then, if that is true and if debug.cpp::value(arg) returns NONE, throw
the error.
None of the two seems elegant to me so I'm guessing there is a better
way. Any ideas?
You can make a function
bool Debug::isKnownValue(string const & val)
Then in LyX.cpp::parse_dbg:
if (Debug::isKnownValue(arg)) {
..
} else {
docstring const error_message =
bformat(_("The following debug flag does not exist:\n %1$s\n"
"Please see 'lyx -dbg' for a list of valid debug flags."),
from_utf8(tmp));
lyxerr << to_utf8(error_message) << endl;
exit(0);
}
Vincent
I think this is something I need to get used to: I would not have
thought that this duplication of code (e.g. reparsing the string in
the same way) was a good solution but I do see this a lot in C++ so
it's something I need learn.
What do you mean ?
Vincent