From e484372bf3f618eb30b8e6970fd13efa20c48509 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 11 Jun 2015 19:48:49 +0300 Subject: add error message formatting functions --- utils/cxx/include/aesnixx/error.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'utils/cxx/include') diff --git a/utils/cxx/include/aesnixx/error.hpp b/utils/cxx/include/aesnixx/error.hpp index af61a32..db390ea 100644 --- a/utils/cxx/include/aesnixx/error.hpp +++ b/utils/cxx/include/aesnixx/error.hpp @@ -10,7 +10,11 @@ #include +#include + #include +#include +#include namespace aesni { @@ -24,8 +28,13 @@ namespace aesni ~ErrorDetailsThrowsInDestructor() { - if (m_impl.ec != AESNI_ERROR_SUCCESS) - throw std::runtime_error(aesni_strerror(m_impl.ec)); + if (aesni_get_error_code(get()) != AESNI_ERROR_SUCCESS) + { + std::vector msg; + msg.resize(aesni_format_error(get(), NULL, 0)); + aesni_format_error(get(), msg.data(), msg.size()); + throw std::runtime_error(std::string(msg.begin(), msg.end())); + } } AesNI_ErrorDetails* get() { return &m_impl; } -- cgit v1.2.3