exceptions

This commit is contained in:
James Cherry 2020-03-15 19:58:05 -07:00
parent 71b643b0f1
commit 0cee0731ab
4 changed files with 6 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -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."; }
};

View File

@ -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 *

View File

@ -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_;