From 7a6cdde571ef3346229b476f04df855ecc363ddd Mon Sep 17 00:00:00 2001 From: Scott Kostyshak Date: Sun, 2 Sep 2012 00:39:20 -0400 Subject: [PATCH] Code Cleanup - Constify some catches. --- src/TDB2.cpp | 2 +- src/commands/CmdEdit.cpp | 2 +- src/commands/CmdMerge.cpp | 2 +- src/commands/CmdShell.cpp | 2 +- src/main.cpp | 2 +- test/date.t.cpp | 2 +- test/dom.t.cpp | 2 +- test/i18n.t.cpp | 2 +- test/json.t.cpp | 2 +- test/nibbler.t.cpp | 2 +- test/t2.t.cpp | 10 +++++----- test/taskmod.t.cpp | 4 ++-- test/tdb2.t.cpp | 2 +- test/view.t.cpp | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index c9d556c5e..dda083dea 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -319,7 +319,7 @@ void TF2::load_tasks () _loaded_tasks = true; } - catch (std::string& e) + catch (const std::string& e) { throw e + format (STRING_TDB2_PARSE_ERROR, _file._data, line_number); } diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index aba5e3531..70014e438 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -811,7 +811,7 @@ ARE_THESE_REALLY_HARMFUL: parseTask (task, after, dateformat); } - catch (std::string& e) + catch (const std::string& e) { problem = e; oops = true; diff --git a/src/commands/CmdMerge.cpp b/src/commands/CmdMerge.cpp index 81e9d1196..60022f7e3 100644 --- a/src/commands/CmdMerge.cpp +++ b/src/commands/CmdMerge.cpp @@ -97,7 +97,7 @@ int CmdMerge::execute (std::string& output) { context.tdb2.merge (file); } - catch (std::string& e) { + catch (const std::string& e) { if (e == STRING_TDB2_UP_TO_DATE) { output += e + "\n"; diff --git a/src/commands/CmdShell.cpp b/src/commands/CmdShell.cpp index c3e5631db..759a91a55 100644 --- a/src/commands/CmdShell.cpp +++ b/src/commands/CmdShell.cpp @@ -111,7 +111,7 @@ int CmdShell::execute (std::string&) context.run (); } - catch (std::string& error) + catch (const std::string& error) { std::cerr << error << "\n"; } diff --git a/src/main.cpp b/src/main.cpp index 7eec0d93a..c53f94e13 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,7 +74,7 @@ int main (int argc, const char** argv) status = context.run (); } - catch (std::string& error) + catch (const std::string& error) { std::cerr << error << "\n"; status = -1; diff --git a/test/date.t.cpp b/test/date.t.cpp index 59b39b25b..f8944f822 100644 --- a/test/date.t.cpp +++ b/test/date.t.cpp @@ -402,7 +402,7 @@ int main (int argc, char** argv) t.is (r26.toString ("YMDHNS"), "20100314235959", "increment across spring DST boundary"); } - catch (std::string& e) + catch (const std::string& e) { t.fail ("Exception thrown."); t.diag (e); diff --git a/test/dom.t.cpp b/test/dom.t.cpp index f9f5f3a55..66469a370 100644 --- a/test/dom.t.cpp +++ b/test/dom.t.cpp @@ -69,7 +69,7 @@ int main (int argc, char** argv) // TODO dom.set rc.name } - catch (std::string& error) + catch (const std::string& error) { t.diag (error); return -1; diff --git a/test/i18n.t.cpp b/test/i18n.t.cpp index 707de88ec..ba4078d9e 100644 --- a/test/i18n.t.cpp +++ b/test/i18n.t.cpp @@ -58,7 +58,7 @@ int main (int argc, char** argv) t.is (format ("pre {3}{1}{2} post", "one", "two", "three"), "pre threeonetwo post", "format 3b"); } - catch (std::string& error) + catch (const std::string& error) { t.diag (error); return -1; diff --git a/test/json.t.cpp b/test/json.t.cpp index f21516f5f..621c4f3b8 100644 --- a/test/json.t.cpp +++ b/test/json.t.cpp @@ -175,7 +175,7 @@ int main (int argc, char** argv) t.is (json::decode (encoded), "one\\", "json::decode one\\\\\\\\ -> one\\\\"); } - catch (std::string& e) {t.diag (e);} + catch (const std::string& e) {t.diag (e);} return 0; } diff --git a/test/nibbler.t.cpp b/test/nibbler.t.cpp index 0263bc016..b07be91dc 100644 --- a/test/nibbler.t.cpp +++ b/test/nibbler.t.cpp @@ -747,7 +747,7 @@ int main (int argc, char** argv) t.is (n.next (1), "b", " 'bcde' : skip () -> 'b'"); } - catch (std::string& e) {t.diag (e);} + catch (const std::string& e) {t.diag (e);} return 0; } diff --git a/test/t2.t.cpp b/test/t2.t.cpp index d91f615d3..7fb16598e 100644 --- a/test/t2.t.cpp +++ b/test/t2.t.cpp @@ -42,33 +42,33 @@ int main (int argc, char** argv) Task task; try {task = Task ("");} - catch (std::string& e){t.diag (e); good = false;} + catch (const std::string& e){t.diag (e); good = false;} t.notok (good, "Task::Task ('')"); // [] good = true; try {task = Task ("[]");} - catch (std::string& e){t.diag (e); good = false;} + catch (const std::string& e){t.diag (e); good = false;} t.notok (good, "Task::Task ('[]')"); // [name:"value"] good = true; try {task = Task ("[name:\"value\"]");} - catch (std::string& e){t.diag (e); good = false;} + catch (const std::string& e){t.diag (e); good = false;} t.ok (good, "Task::Task ('[name:\"value\"]')"); t.is (task.get ("name"), "value", "name=value"); // [name:"one two"] good = true; try {task = Task ("[name:\"one two\"]");} - catch (std::string& e){t.diag (e); good = false;} + catch (const std::string& e){t.diag (e); good = false;} t.ok (good, "Task::Task ('[name:\"one two\"]')"); t.is (task.get ("name"), "one two", "name=one two"); // [one:two three:four] good = true; try {task = Task ("[one:\"two\" three:\"four\"]");} - catch (std::string& e){t.diag (e); good = false;} + catch (const std::string& e){t.diag (e); good = false;} t.ok (good, "Task::Task ('[one:\"two\" three:\"four\"]')"); t.is (task.get ("one"), "two", "one=two"); t.is (task.get ("three"), "four", "three=four"); diff --git a/test/taskmod.t.cpp b/test/taskmod.t.cpp index fa7fc4d45..d0516d6f5 100644 --- a/test/taskmod.t.cpp +++ b/test/taskmod.t.cpp @@ -75,7 +75,7 @@ int main (int argc, char** argv) good = true; try { empty.getUuid(); - } catch (std::string& e) { t.diag(e); good = false; } + } catch (const std::string& e) { t.diag(e); good = false; } t.notok (good, "Taskmod::getUuid() not"); // issetAfter() not @@ -87,7 +87,7 @@ int main (int argc, char** argv) try { std::string uuid = newMod.getUuid(); t.is(uuid, "df95dac3-5f2b-af88-5416-03a3163d00fd", "Taskmod::getUuid()"); - } catch (std::string& e) { + } catch (const std::string& e) { t.diag(e); t.fail("Taskmod::getUuid()"); } diff --git a/test/tdb2.t.cpp b/test/tdb2.t.cpp index 38f693d5b..4005cacac 100644 --- a/test/tdb2.t.cpp +++ b/test/tdb2.t.cpp @@ -126,7 +126,7 @@ int main (int argc, char** argv) // TODO gc } - catch (std::string& error) + catch (const std::string& error) { t.diag (error); return -1; diff --git a/test/view.t.cpp b/test/view.t.cpp index 2597ebf60..b71adbddc 100644 --- a/test/view.t.cpp +++ b/test/view.t.cpp @@ -175,7 +175,7 @@ int main (int argc, char** argv) t.ok (string_view.lines () > 4, "View::lines > 4"); } - catch (std::string& e) + catch (const std::string& e) { t.fail ("Exception thrown."); t.diag (e);