summaryrefslogtreecommitdiffstats
path: root/crypt/cryptexception.h
blob: 768e1446180ab7980f54b63df9e596dae16326bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef CRYPTEXCEPTION_H
#define CRYPTEXCEPTION_H

#include <exception>

#include <QString>

class CryptException : public std::exception
{
public:
    /**
     * @brief The ReturnCode enum
     */
    enum ReturnCode
    {
        FileNotFound = 1,
        FileNotWritable,
        DecryptionErrorRsa,
        DecryptionErrorAes,
        OpenSslError,
        KeyNotRsa,
        CsprngNotSeeded,
        NoUserKeyCreated
    };

    /**
     * @brief CryptException
     * Erzeugt eine Exception mit den angegebenen Werten.
     * @param what Die Fehlermeldung, die dem Nutzer gezeigt wird.
     * @param returnCode Der Rückgabewert für die Konsole.
     */
    CryptException(std::string what, ReturnCode returnCode);

    /**
     * @brief ~CryptException
     */
    virtual ~CryptException() throw();

    /**
     * @brief what
     * Gibt die Fehlermelung für den Nutzer zurück.
     * @return Die Fehlermeldung für den Nutzer.
     */
    virtual const char *what() const throw();

    /**
     * @brief returnCode
     * Gibt den Konsolenrückgabewert zurück.
     * @return Der Rückgabewert für die Konsole.
     */
    ReturnCode returnCode() const;

private:
    std::string whatMsg;
    ReturnCode retId;

};

#endif // CRYPTEXCEPTION_H