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?

Thanks,

Scott
---
 src/support/debug.cpp |   23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/support/debug.cpp b/src/support/debug.cpp
index 3a6f901..8ff3f3a 100644
--- a/src/support/debug.cpp
+++ b/src/support/debug.cpp
@@ -127,13 +127,24 @@ Debug::Type Debug::value(string const & val)
                // Is it a number?
                if (isStrInt(tmp))
                        l |= static_cast<Type>(convert<int>(tmp));
-               else
-               // Search for an explicit name
-               for (int i = 0 ; i < numErrorTags ; ++i)
-                       if (tmp == errorTags[i].name) {
-                               l |= errorTags[i].level;
-                               break;
+               else {
+                       // Search for an explicit name
+                       bool foundMatch = false;
+                       for (int i = 0 ; i < numErrorTags ; ++i)
+                               if (tmp == errorTags[i].name) {
+                                       foundMatch = true;
+                                       l |= errorTags[i].level;
+                                       break;
+                               }
+                       if (!foundMatch) {
+                               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;
+                               //throw error.
                        }
+               }
                if (st == string::npos)
                break;
                v.erase(0, st + 1);
-- 
1.7.9.5

Reply via email to