Virgil Security Crypto library  2.5.0-rc1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
VirgilCryptoError.h
1 
37 #ifndef VIRGIL_CRYPTO_ERROR_H
38 #define VIRGIL_CRYPTO_ERROR_H
39 
40 #include <limits>
41 #include <system_error>
42 
43 #include "VirgilCryptoException.h"
44 
45 namespace virgil { namespace crypto {
46 
51 enum class VirgilCryptoError {
52  Reserved = 0,
61  InvalidState,
62  InvalidAuth,
67  NotSecure,
69  FileNotFound,
70  FileTooSmall,
71  Undefined = std::numeric_limits<int>::max()
72 };
73 
78 class VirgilCryptoErrorCategory : public std::error_category {
79 public:
83  const char* name() const noexcept override;
84 
91  std::string message(int ev) const noexcept override;
92 };
93 
100 
109  return VirgilCryptoException(static_cast<int>(ev), crypto_category());
110 }
111 
120 inline VirgilCryptoException make_error(VirgilCryptoError ev, const std::string& what) {
121  return VirgilCryptoException(static_cast<int>(ev), crypto_category(), what);
122 }
123 
132 inline VirgilCryptoException make_error(VirgilCryptoError ev, const char* what) {
133  return VirgilCryptoException(static_cast<int>(ev), crypto_category(), what);
134 }
135 }}
136 
137 
138 #endif //VIRGIL_CRYPTO_ERROR_H
Invalid format of the Public Key.
File is not found under given path.
VirgilCryptoError
Specific error codes for the crypto library.
Definition: VirgilCryptoError.h:51
Security prerequisite is broken.
Structure maximum size was exceeded.
Algorithm is not supported in the current build.
Recipient with given identifier is not found.
Function call prerequisite is broken.
const VirgilCryptoErrorCategory & crypto_category() noexcept
Return singleton instance of the crypto error category.
This is specific error category that contains information about crypto library errors.
Definition: VirgilCryptoError.h:78
Argument given to a function is invalid.
VirgilCryptoException make_error(VirgilCryptoError ev)
Build exception with given error value and corresond error category.
Definition: VirgilCryptoError.h:108
Object is not initialized with specific algorithm, so can't be used.
This only exception that crypto library can produce.
Definition: VirgilCryptoException.h:54
const char * name() const noexceptoverride
std::string message(int ev) const noexceptoverride
Invalid format of the Private Key.
Data within file is not enough for algorithm.
Recipient with given password is not found.
Given parameter is null or empty.