From 0cee0731aba77768b36bbd993677e7b85e489571 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Sun, 15 Mar 2020 19:58:05 -0700 Subject: [PATCH] exceptions --- tcl/Exception.i | 3 ++- tcl/StaTcl.i | 4 ++-- util/PatternMatch.cc | 3 +-- util/PatternMatch.hh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tcl/Exception.i b/tcl/Exception.i index d4f8cb67..d7d0b893 100644 --- a/tcl/Exception.i +++ b/tcl/Exception.i @@ -25,7 +25,8 @@ exit(0); } catch (std::exception &excp) { - Tcl_AppendResult(interp, "Error: ", excp.what(), nullptr); + char *msg = stringPrint("Error: %s", excp.what()); + Tcl_SetResult(interp, msg, nullptr); return TCL_ERROR; } } diff --git a/tcl/StaTcl.i b/tcl/StaTcl.i index 11d31cf6..0bfc1212 100644 --- a/tcl/StaTcl.i +++ b/tcl/StaTcl.i @@ -112,14 +112,14 @@ class CmdErrorNetworkNotLinked : public Exception { public: virtual const char *what() const noexcept - { return "Error: no network has been linked."; } + { return "no network has been linked."; } }; class CmdErrorNetworkNotEditable : public Exception { public: virtual const char *what() const noexcept - { return "Error: network does not support edits."; } + { return "network does not support edits."; } }; diff --git a/util/PatternMatch.cc b/util/PatternMatch.cc index 2bca3e18..6fea5eed 100644 --- a/util/PatternMatch.cc +++ b/util/PatternMatch.cc @@ -116,8 +116,7 @@ PatternMatch::matchNoCase(const char *str) const RegexpCompileError::RegexpCompileError(const char *pattern) : Exception() { - const char *msg = "Error: TCL failed to compile regular expression '%s'."; - error_ = stringPrintTmp(msg, pattern); + error_ = stringPrint("TCL failed to compile regular expression '%s'.", pattern); } const char * diff --git a/util/PatternMatch.hh b/util/PatternMatch.hh index 17bb5266..bfd265c2 100644 --- a/util/PatternMatch.hh +++ b/util/PatternMatch.hh @@ -69,7 +69,7 @@ class RegexpCompileError : public Exception public: explicit RegexpCompileError(const char *error); virtual ~RegexpCompileError() noexcept {} - virtual const char *what() const throw(); + virtual const char *what() const noexcept; private: const char *error_;