akabeierror.h 2.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/* This file is part of the Chakra project

   Copyright (C) 2010 Dario Freddi <drf@chakra-project.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
*/

#ifndef AKABEI_AKABEIERROR_H
#define AKABEI_AKABEIERROR_H

14 15
#include <QtCore/QString>
#include <QtCore/QList>
16 17 18 19 20

namespace Akabei {
class Package;
class Operation;

Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
21
/**
Lukas Appelhans's avatar
Lukas Appelhans committed
22
 * \class Error akabeierror.h "akabeierror.h"
Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
23 24 25
 *
 * \brief Class for describing an error which occurred.
 */
26 27 28
class Error
{
    public:
Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
29 30 31 32 33
        /**
         * \enum Type
         * This enum describes the type of error which occurred.
         * @see type()
         */
34 35 36 37 38 39
        enum Type {
            UnknownError = 0,
            FilesystemConflictError = 1,
            PackageConflictError = 2,
            DuplicateTargetError = 3,
            UnresolvableDependenciesError = 4,
Lukas Appelhans's avatar
Lukas Appelhans committed
40
            DatabaseError = 5,
41
            ScripletError = 6,
42 43 44 45 46
            //
            GenericError = 128,
            AkabeiInternalError = 129
        };

Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
47 48 49 50 51 52
        /**
         * Creates an new error object.
         * @param type the type of the error
         * @param description the description of the error
         * @param op the operation associated with the error
         */
53 54 55
        explicit Error(Type type, const QString &description = QString(), Operation *op = 0);
        virtual ~Error();

Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
56 57 58
        /**
         * @returns the type of error which occurred
         */
59 60
        Type type() const;

Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
61 62 63
        /**
         * @returns the description of the error
         */
64
        QString description() const;
Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
65 66 67 68 69
        
        /**
         * Sets a new description of the error.
         * @param description the new description
         */
70 71
        void setDescription(const QString &description);

Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
72 73 74
        /**
         * @returns the operation in which the error occurred. Can theoretically be 0.
         */
75
        Operation *operation();
Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
76 77 78 79 80
        
        /**
         * Sets a new operation associated with the error
         * @param op the new operation associated with the error
         */
81
        void setOperation(Operation *op);
82

Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
83 84 85
        /**
         * @returns the targets which are associated with the error
         */
86
        QList<Package*> targets() const;
Lukas Appelhans's avatar
Docu  
Lukas Appelhans committed
87 88 89 90 91
        
        /**
         * Sets new targets associated with the error
         * @param targets the new targets associated with the error
         */
92 93 94 95
        void setTargets(const QList<Package*> &targets);

    private:
        class Private;
96
        Private * const d;
97 98 99 100 101
};

}

#endif // AKABEI_AKABEIERROR_H