Virgil Security Crypto library  2.6.3
VirgilPythiaError.h
1 
37 #ifndef VIRGIL_PYTHIA_ERROR_H
38 #define VIRGIL_PYTHIA_ERROR_H
39 
40 #include <system_error>
41 
42 #include "../VirgilCryptoError.h"
43 
44 namespace virgil {
45 namespace crypto {
46 namespace pythia {
47 
53 class VirgilPythiaErrorCategory : public std::error_category {
54 public:
59  const char* name() const noexcept override;
60 
66  std::string message(int ev) const noexcept override;
67 };
68 
75 
88 inline int pythia_handler_get_result(int result) {
89  if (result >= 0) {
90  return result;
91  }
93 }
94 
106 inline void pythia_handler(int result) {
107  (void)pythia_handler_get_result(result);
108 }
109 
125 template <typename CatchHandler>
126 inline int pythia_handler_get_result(int result, CatchHandler catch_handler) {
127  if (result >= 0) {
128  return result;
129  }
130  try {
132  } catch (...) {
133  catch_handler(result);
134  return 0;
135  }
136 }
137 
152 template <typename CatchHandler>
153 inline void pythia_handler(int result, CatchHandler catch_handler) {
154  (void)pythia_handler_get_result<CatchHandler>(result, catch_handler);
155 }
156 
157 } // namespace pythia
158 } // namespace crypto
159 } // namespace virgil
160 
161 #endif // VIRGIL_PYTHIA_ERROR_H
int pythia_handler_get_result(int result, CatchHandler catch_handler)
Handle value returned by underling system crypto library.
Definition: VirgilPythiaError.h:126
std::string message(int ev) const noexceptoverride
Return description for the given error code.
const char * name() const noexceptoverride
Return name of the system crypto category.
Root namespace for all Virgil Security libraries.
Definition: VirgilAsn1Compatible.h:46
void pythia_handler(int result, CatchHandler catch_handler)
Handle value returned by underling system crypto library.
Definition: VirgilPythiaError.h:153
const VirgilPythiaErrorCategory & pythia_error_category() noexcept
Return singleton instance of the system crypto error category.
This only exception that crypto library can produce.
Definition: VirgilCryptoException.h:54
Error category that handles error codes from the system crypto library.
Definition: VirgilPythiaError.h:53