source: SMSSender/lib/libdatatypes/src/exceptions/elibraryloadexception.h @ 72:fc91522ef9be

3.0
Last change on this file since 72:fc91522ef9be was 72:fc91522ef9be, checked in by Sämy Zehnder <saemy.zehnder@…>, 9 years ago
  • Started exception handling
  • Fixed several bugs from the removal of the iloginaccount gateway
File size: 1.5 KB
Line 
1/*
2 * ELibraryLoadException.h
3 *
4 *  Created on: Jan 4, 2010
5 *      Author: saemy
6 */
7
8#ifndef ELIBRARYLOADEXCEPTION_H_
9#define ELIBRARYLOADEXCEPTION_H_
10
11#include <QString>
12
13#include "eexception.h"
14
15namespace Library {
16    class ELoadException: EException {
17    public:
18        enum Purpose {
19            FileNotFound,
20            InvalidLibraryFile,
21            VersionMismatch,
22            Other,
23            Unknown
24        };
25
26        explicit ELoadException(const QString& message)
27            : purpose_(Other)
28            , msgStr_(message)
29        {};
30        explicit ELoadException(const Purpose& purpose)
31            : purpose_ (purpose)
32        {};
33
34        Purpose purpose() const throw() { return purpose_; }
35        QString toString() const throw() {
36            QString msg = QObject::tr("Loading the library failed: ");
37            switch (purpose()) {
38            case FileNotFound:
39                return msg + QObject::tr("Could not find the file");
40            case InvalidLibraryFile:
41                return msg + QObject::tr("The given file is no library");
42            case VersionMismatch:
43                return msg + QObject::tr("The given library has an invalid version");
44            case Other:
45                return msg + msgStr_;
46            case Unknown:
47            default:
48                return msg + QObject::tr("Unknown error");
49            }
50        }
51
52    private:
53        Purpose purpose_;
54        QString msgStr_;
55    };
56}
57
58#endif /* ELIBRARYLOADEXCEPTION_H_ */
Note: See TracBrowser for help on using the repository browser.