aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/common.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-11 03:25:03 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-11 03:25:03 +0300
commit35f3497d371a0a05098fcfdbe6e40d91095ef06c (patch)
treeb9bbce2bf6c8b16b1ab837743425c29b4c4e2bf4 /utils/common.hpp
parentadd `assert`s (diff)
downloadaes-tools-35f3497d371a0a05098fcfdbe6e40d91095ef06c.tar.gz
aes-tools-35f3497d371a0a05098fcfdbe6e40d91095ef06c.zip
add error codes & messages to the library
Diffstat (limited to '')
-rw-r--r--utils/common.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/utils/common.hpp b/utils/common.hpp
new file mode 100644
index 0000000..af61a32
--- /dev/null
+++ b/utils/common.hpp
@@ -0,0 +1,38 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#pragma once
+
+#include <aesni/all.h>
+
+#include <stdexcept>
+
+namespace aesni
+{
+ class ErrorDetailsThrowsInDestructor
+ {
+ public:
+ ErrorDetailsThrowsInDestructor()
+ {
+ aesni_make_error_success(get());
+ }
+
+ ~ErrorDetailsThrowsInDestructor()
+ {
+ if (m_impl.ec != AESNI_ERROR_SUCCESS)
+ throw std::runtime_error(aesni_strerror(m_impl.ec));
+ }
+
+ AesNI_ErrorDetails* get() { return &m_impl; }
+
+ operator AesNI_ErrorDetails*() { return get(); }
+
+ private:
+ AesNI_ErrorDetails m_impl;
+ };
+}