Add ReadFileError.
authorCarl Hetherington <cth@carlh.net>
Tue, 24 Jul 2012 19:50:39 +0000 (20:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 24 Jul 2012 19:50:39 +0000 (20:50 +0100)
src/lib/exceptions.h

index b16275c20696482ffb0d322b432372d8de15b39e..be5959d642b5bb255a080c08bcbd572b6ab6df6d 100644 (file)
@@ -117,6 +117,28 @@ public:
        {}
 };
 
+
+/** @class ReadFileError.
+ *  @brief Indicates that some error occurred when trying to write to a file
+ */
+class ReadFileError : public FileError
+{
+public:
+       /** @param f File that we were trying to read from.
+        *  @param e errno value, or 0.
+        */
+       ReadFileError (std::string f, int e)
+               : FileError ("", f)
+       {
+               std::stringstream s;
+               s << "could not read from file " << f;
+               if (e) {
+                       s << " (" << strerror (e) << ")";
+               }
+               _what = s.str ();
+       }
+};
+
 /** @class WriteFileError.
  *  @brief Indicates that some error occurred when trying to write to a file
  */