Virgil Security Crypto library  1.8.2
PolarsslException.h
1 
37 #ifndef VIRGIL_CRYPTO_MBEDTLS_EXCEPTION_H
38 #define VIRGIL_CRYPTO_MBEDTLS_EXCEPTION_H
39 
40 #include <virgil/crypto/VirgilCryptoException.h>
41 
42 #define MBEDTLS_ERROR_HANDLER(invocation) MBEDTLS_ERROR_HANDLER_DISPOSE(invocation, {})
43 
44 #define MBEDTLS_ERROR_HANDLER_DISPOSE(invocation, dispose) \
45 do { \
46  int errCode__ = invocation; \
47  if (errCode__ < 0) { \
48  do { dispose; } while (0); \
49  throw PolarsslException(errCode__); \
50  } \
51 } while (0)
52 
53 #define MBEDTLS_ERROR_HANDLER_CLEANUP(errCode, invocation) \
54 do { errCode = invocation; if (errCode < 0) { goto cleanup; } } while (0)
55 
56 #define MBEDTLS_ERROR_MESSAGE_CLEANUP(messageVariable, message) \
57 do { messageVariable = message; goto cleanup; } while (0)
58 
59 #define MBEDTLS_ERROR_MESSAGE_HANDLER(messageVariable) \
60 do { if (messageVariable) throw VirgilCryptoException(messageVariable); } while (0)
61 
62 
63 namespace virgil { namespace crypto { namespace foundation {
64 
69 public:
73 
80  explicit PolarsslException(int errCode);
82 
85  virtual ~PolarsslException() throw();
88 
91 
96  int errCode() const throw();
98 private:
99  int errCode_;
100 };
101 
102 }}}
103 
104 #endif /* VIRGIL_CRYPTO_MBEDTLS_EXCEPTION_H */
105 
int errCode() const
Provide low-level PolarSSL fremowork error code.
Definition: VirgilAsn1Compatible.h:46
Encapsulates low-level domain error of the PolarSSL framework.
Definition: PolarsslException.h:68
PolarsslException(int errCode)
Creates PolarsslException class object for a given error code.
Encapsulates logic errors of module 'crypto'.
Definition: VirgilCryptoException.h:48