added error code output

This commit is contained in:
vladimir.kuznetsov 2023-12-24 21:11:47 +07:00
parent 5ad54bfdc1
commit 11641c5e22
2 changed files with 120 additions and 101 deletions

View file

@ -4,77 +4,92 @@
#include <QMetaEnum>
#include <QObject>
namespace amnezia {
constexpr const qint16 qrMagicCode = 1984;
struct ServerCredentials
namespace amnezia
{
QString hostName;
QString userName;
QString secretData;
int port = 22;
bool isValid() const { return !hostName.isEmpty() && !userName.isEmpty() && !secretData.isEmpty() && port > 0; }
};
constexpr const qint16 qrMagicCode = 1984;
enum ErrorCode
{
// General error codes
NoError = 0,
UnknownError,
InternalError,
NotImplementedError,
struct ServerCredentials
{
QString hostName;
QString userName;
QString secretData;
int port = 22;
// Server errors
ServerCheckFailed,
ServerPortAlreadyAllocatedError,
ServerContainerMissingError,
ServerDockerFailedError,
ServerCancelInstallation,
ServerUserNotInSudo,
ServerPacketManagerError,
bool isValid() const
{
return !hostName.isEmpty() && !userName.isEmpty() && !secretData.isEmpty() && port > 0;
}
};
// Ssh connection errors
SshRequestDeniedError, SshInterruptedError, SshInternalError,
SshPrivateKeyError, SshPrivateKeyFormatError, SshTimeoutError,
enum ErrorCode {
// General error codes
NoError = 0,
UnknownError = 1,
InternalError = 2,
NotImplementedError = 3,
// Ssh sftp errors
SshSftpEofError, SshSftpNoSuchFileError, SshSftpPermissionDeniedError,
SshSftpFailureError, SshSftpBadMessageError, SshSftpNoConnectionError,
SshSftpConnectionLostError, SshSftpOpUnsupportedError, SshSftpInvalidHandleError,
SshSftpNoSuchPathError, SshSftpFileAlreadyExistsError, SshSftpWriteProtectError,
SshSftpNoMediaError,
// Server errors
ServerCheckFailed = 4,
ServerPortAlreadyAllocatedError = 5,
ServerContainerMissingError = 6,
ServerDockerFailedError = 7,
ServerCancelInstallation = 8,
ServerUserNotInSudo = 9,
ServerPacketManagerError = 10,
// Local errors
OpenVpnConfigMissing,
OpenVpnManagementServerError,
ConfigMissing,
// Ssh connection errors
SshRequestDeniedError = 11,
SshInterruptedError = 12,
SshInternalError = 13,
SshPrivateKeyError = 14,
SshPrivateKeyFormatError = 15,
SshTimeoutError = 16,
// Distro errors
OpenVpnExecutableMissing,
ShadowSocksExecutableMissing,
CloakExecutableMissing,
AmneziaServiceConnectionFailed,
ExecutableMissing,
// Ssh sftp errors
SshSftpEofError = 17,
SshSftpNoSuchFileError = 18,
SshSftpPermissionDeniedError = 19,
SshSftpFailureError = 20,
SshSftpBadMessageError = 21,
SshSftpNoConnectionError = 22,
SshSftpConnectionLostError = 23,
SshSftpOpUnsupportedError = 24,
SshSftpInvalidHandleError = 25,
SshSftpNoSuchPathError = 26,
SshSftpFileAlreadyExistsError = 27,
SshSftpWriteProtectError = 28,
SshSftpNoMediaError = 29,
// VPN errors
OpenVpnAdaptersInUseError,
OpenVpnUnknownError,
OpenVpnTapAdapterError,
AddressPoolError,
// Local errors
OpenVpnConfigMissing = 30,
OpenVpnManagementServerError = 31,
ConfigMissing = 32,
// 3rd party utils errors
OpenSslFailed,
ShadowSocksExecutableCrashed,
CloakExecutableCrashed,
// Distro errors
OpenVpnExecutableMissing = 33,
ShadowSocksExecutableMissing = 34,
CloakExecutableMissing = 35,
AmneziaServiceConnectionFailed = 36,
ExecutableMissing = 37,
// import and install errors
ImportInvalidConfigError,
// VPN errors
OpenVpnAdaptersInUseError = 38,
OpenVpnUnknownError = 39,
OpenVpnTapAdapterError = 40,
AddressPoolError = 41,
// Android errors
AndroidError
};
// 3rd party utils errors
OpenSslFailed = 42,
ShadowSocksExecutableCrashed = 43,
CloakExecutableCrashed = 44,
// import and install errors
ImportInvalidConfigError = 45,
// Android errors
AndroidError = 46
};
} // namespace amnezia