Small use of String::compose.
authorCarl Hetherington <cth@carlh.net>
Tue, 12 Feb 2013 22:32:08 +0000 (22:32 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 12 Feb 2013 22:32:08 +0000 (22:32 +0000)
src/lib/exceptions.h

index e757d25069c9182455c5185aeb2183664c2c7a17..6de8806e4e8debc24eeef6100235a9a44498f96f 100644 (file)
  */
 
 #include <stdexcept>
-#include <sstream>
 #include <cstring>
 #include <boost/exception/all.hpp>
 #include <boost/thread.hpp>
+#include "compose.hpp"
 
 /** @class StringError
  *  @brief A parent class for exceptions using messages held in a std::string
@@ -140,12 +140,7 @@ public:
        ReadFileError (std::string f, int e = 0)
                : FileError ("", f)
        {
-               std::stringstream s;
-               s << "could not read from file " << f;
-               if (e) {
-                       s << " (" << strerror (e) << ")";
-               }
-               _what = s.str ();
+               _what = String::compose ("could not read from file %1 (%2)", f, strerror (e));
        }
 };
 
@@ -161,12 +156,7 @@ public:
        WriteFileError (std::string f, int e)
                : FileError ("", f)
        {
-               std::stringstream s;
-               s << "could not write to file " << f;
-               if (e) {
-                       s << " (" << strerror (e) << ")";
-               }
-               _what = s.str ();
+               _what = String::compose ("could not write to file %1 (%2)", f, strerror (e));
        }
 };