mirror of
https://github.com/QRouland/UTPass.git
synced 2026-01-10 03:26:57 +00:00
Improve Lib Pass Error Messages
This commit is contained in:
@@ -6,25 +6,66 @@ extern "C" {
|
||||
#include "rnp/rnp_err.h"
|
||||
}
|
||||
|
||||
enum ErrorCodeShow {
|
||||
UnexceptedError= 1,
|
||||
enum class ErrorCodeShow {
|
||||
Success= 0,
|
||||
UnexceptedError,
|
||||
BadPassphrase,
|
||||
NoKeyFound,
|
||||
DecryptFailed
|
||||
};
|
||||
|
||||
ErrorCodeShow rnpErrorToErrorCodeShow(int rnpErrorCode) {
|
||||
int rnpErrorToErrorCodeShow(int rnpErrorCode) {
|
||||
switch (rnpErrorCode) {
|
||||
case RNP_SUCCESS:
|
||||
return static_cast<int>(ErrorCodeShow::Success);
|
||||
case RNP_ERROR_BAD_PASSWORD:
|
||||
return BadPassphrase;
|
||||
return static_cast<int>(ErrorCodeShow::BadPassphrase);
|
||||
case RNP_ERROR_KEY_NOT_FOUND:
|
||||
case RNP_ERROR_NO_SUITABLE_KEY:
|
||||
return NoKeyFound;
|
||||
return static_cast<int>(ErrorCodeShow::NoKeyFound);
|
||||
case RNP_ERROR_DECRYPT_FAILED:
|
||||
return DecryptFailed;
|
||||
return static_cast<int>(ErrorCodeShow::DecryptFailed);
|
||||
default:
|
||||
return UnexceptedError;
|
||||
return static_cast<int>(ErrorCodeShow::UnexceptedError);
|
||||
}
|
||||
}
|
||||
|
||||
enum class ErrorCodeImportKeyFile {
|
||||
Success= 0,
|
||||
UnexceptedError,
|
||||
BadFormat,
|
||||
};
|
||||
|
||||
int rnpErrorToErrorCodeImportKeyFile(int rnpErrorCode) {
|
||||
switch (rnpErrorCode) {
|
||||
case RNP_SUCCESS:
|
||||
return static_cast<int>(ErrorCodeShow::Success);
|
||||
case RNP_ERROR_BAD_FORMAT:
|
||||
return static_cast<int>(ErrorCodeImportKeyFile::BadFormat);
|
||||
default:
|
||||
return static_cast<int>(ErrorCodeImportKeyFile::UnexceptedError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum class ErrorCodeUnexvepted {
|
||||
Success= 0,
|
||||
UnexceptedError,
|
||||
};
|
||||
|
||||
int rnpErrorToErrorCodeGeneric(int rnpErrorCode) {
|
||||
switch (rnpErrorCode) {
|
||||
case RNP_SUCCESS:
|
||||
return static_cast<int>(ErrorCodeShow::Success);
|
||||
default:
|
||||
return static_cast<int>(ErrorCodeImportKeyFile::UnexceptedError);
|
||||
}
|
||||
}
|
||||
|
||||
enum class ErrorCode
|
||||
{
|
||||
Success= 0,
|
||||
Error,
|
||||
};
|
||||
|
||||
#endif // ERROR_H
|
||||
|
||||
Reference in New Issue
Block a user