From: Avi Kivity <a...@redhat.com>

Signed-off-by: Avi Kivity <a...@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosa...@redhat.com>

diff --git a/api/exception.cc b/api/exception.cc
new file mode 100644
index 0000000..500569a
--- /dev/null
+++ b/api/exception.cc
@@ -0,0 +1,20 @@
+#include "exception.hh"
+#include <cstdio>
+#include <cstring>
+
+errno_exception::errno_exception(int errno)
+    : _errno(errno)
+{
+}
+
+int errno_exception::errno() const
+{
+    return _errno;
+}
+
+const char *errno_exception::what()
+{
+    std::snprintf(_buf, sizeof _buf, "error: %s (%d)",
+                 std::strerror(_errno), _errno);
+    return _buf;
+}
diff --git a/api/exception.hh b/api/exception.hh
new file mode 100644
index 0000000..4672760
--- /dev/null
+++ b/api/exception.hh
@@ -0,0 +1,16 @@
+#ifndef EXCEPTION_HH
+#define EXCEPTION_HH
+
+#include <exception>
+
+class errno_exception : public std::exception {
+public:
+    explicit errno_exception(int err_no);
+    int errno() const;
+    virtual const char *what();
+private:
+    int _errno;
+    char _buf[1000];
+};
+
+#endif
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to