LeechCraft Azoth
0.6.70-18450-gabe19ee3b0
Modular multiprotocol IM plugin for LeechCraft
Toggle main menu visibility
Loading...
Searching...
No Matches
gpgexceptions.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include <stdexcept>
12
#include <variant>
13
#include <optional>
14
15
namespace
LC
16
{
17
namespace
Azoth
18
{
19
namespace
GPGExceptions
20
{
37
class
General
:
public
std::runtime_error
38
{
39
QString Context_;
40
int
Code_ = -1;
41
QString Message_;
42
public
:
48
General
(
const
QString& context)
49
: std::runtime_error { context.toStdString () }
50
, Context_ { context }
51
{
52
}
53
61
General
(
const
QString& context,
int
code,
const
QString& message)
62
: std::runtime_error
63
{
64
context.toStdString () + std::to_string (code) +
": "
+ message.toStdString ()
65
}
66
, Context_ { context }
67
, Code_ { code }
68
, Message_ { message }
69
{
70
}
71
78
General
(
int
code,
const
QString& msg)
79
:
General
{
"Azoth GPG error"
, code, msg }
80
{
81
}
82
87
const
QString&
GetContext
()
const
88
{
89
return
Context_;
90
}
91
96
int
GetCode
()
const
97
{
98
return
Code_;
99
}
100
105
const
QString&
GetMessage
()
const
106
{
107
return
Message_;
108
}
109
};
110
113
class
NullPubkey
:
public
General
114
{
115
public
:
118
NullPubkey
()
119
:
General
{
"Azoth GPG: null pubkey"
}
120
{
121
}
122
};
123
126
class
Encryption
:
public
General
127
{
128
public
:
136
Encryption
(
int
code,
const
QString& message)
137
:
General
{
"Azoth GPG encryption error"
, code, message }
138
{
139
}
140
};
141
144
using
AnyException_t
= std::variant<Encryption, NullPubkey, General>;
145
148
using
MaybeException_t
= std::optional<AnyException_t>;
149
}
150
}
151
}
LC::Azoth::GPGExceptions::Encryption::Encryption
Encryption(int code, const QString &message)
Constructs the error object using the error code and message.
Definition
gpgexceptions.h:136
LC::Azoth::GPGExceptions::General::GetMessage
const QString & GetMessage() const
Returns the human-readable error message.
Definition
gpgexceptions.h:105
LC::Azoth::GPGExceptions::General::General
General(int code, const QString &msg)
Constructs the error with the given code and error message.
Definition
gpgexceptions.h:78
LC::Azoth::GPGExceptions::General::GetContext
const QString & GetContext() const
Returns the context of the error.
Definition
gpgexceptions.h:87
LC::Azoth::GPGExceptions::General::GetCode
int GetCode() const
Returns the error code, if applicable.
Definition
gpgexceptions.h:96
LC::Azoth::GPGExceptions::General::General
General(const QString &context, int code, const QString &message)
Constructs the error with the given context, code and error message.
Definition
gpgexceptions.h:61
LC::Azoth::GPGExceptions::General::General
General(const QString &context)
Constructs the error with the given context description.
Definition
gpgexceptions.h:48
LC::Azoth::GPGExceptions::NullPubkey::NullPubkey
NullPubkey()
Constructs the error object.
Definition
gpgexceptions.h:118
LC::Azoth::GPGExceptions
Definition
gpgexceptions.h:20
LC::Azoth::GPGExceptions::MaybeException_t
std::optional< AnyException_t > MaybeException_t
A type representing a possibility of a GPG-related error.
Definition
gpgexceptions.h:148
LC::Azoth::GPGExceptions::AnyException_t
std::variant< Encryption, NullPubkey, General > AnyException_t
A sum type of all the possible GPG-related errors.
Definition
gpgexceptions.h:144
LC::Azoth
Definition
activityinfo.h:16
LC
Definition
activityinfo.h:14
src
plugins
azoth
interfaces
azoth
gpgexceptions.h
Generated by
1.17.0