diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-04-27 02:22:14 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-04-27 02:22:14 +0000 |
| commit | 1ef99931e131343f069a4b74edfc06196d72d85b (patch) | |
| tree | d640f061a66a193d5f4d92b61836161208ccff14 /src/Netrc.cc | |
| parent | a7952cce05a41c6e20d6eddc569a8bffe974aade (diff) | |
2008-04-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten Exception class. Throw exception object, not its pointer and
catch by reference, so that remove problematic delete operator for
catched exception.
* src/Exception.cc
* src/Exception.h
* test/ExceptionTest.cc
* src/*: All files throwing/catching exception.
* test/*: All files throwing/catching exception.
Diffstat (limited to 'src/Netrc.cc')
| -rw-r--r-- | src/Netrc.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Netrc.cc b/src/Netrc.cc index 9c73fc66..b593049d 100644 --- a/src/Netrc.cc +++ b/src/Netrc.cc @@ -34,6 +34,7 @@ /* copyright --> */ #include "Netrc.h" #include "RecoverableException.h" +#include "StringFormat.h" #include <fstream> #include <algorithm> @@ -45,7 +46,8 @@ std::string Netrc::getRequiredNextToken(std::ifstream& f) const if(f >> token) { return token; } else { - throw new RecoverableException("Netrc:parse error. EOF reached where a token expected."); + throw RecoverableException + ("Netrc:parse error. EOF reached where a token expected."); } } @@ -66,7 +68,8 @@ void Netrc::parse(const std::string& path) std::ifstream f(path.c_str()); if(!f) { - throw new RecoverableException("File not found: %s", path.c_str()); + throw RecoverableException + (StringFormat("File not found: %s", path.c_str()).str()); } AuthenticatorHandle authenticator; @@ -81,7 +84,8 @@ void Netrc::parse(const std::string& path) authenticator.reset(new DefaultAuthenticator()); } else { if(authenticator.isNull()) { - throw new RecoverableException("Netrc:parse error. %s encounterd where 'machine' or 'default' expected."); + throw RecoverableException + ("Netrc:parse error. %s encounterd where 'machine' or 'default' expected."); } if(token == "login") { authenticator->setLogin(getRequiredNextToken(f)); |
