1 /*
2   Exceptions.h
3 
4   This file is part of Charm, a task-based time tracking application.
5 
6   Copyright (C) 2008-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
7 
8   Author: Mirko Boehm <mirko.boehm@kdab.com>
9 
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License as published by
12   the Free Software Foundation, either version 2 of the License, or
13   (at your option) any later version.
14 
15   This program is distributed in the hope that it will be useful,
16   but WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   GNU General Public License for more details.
19 
20   You should have received a copy of the GNU General Public License
21   along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef EXCEPTIONS_H
25 #define EXCEPTIONS_H
26 
27 #include <exception>
28 #include <QString>
29 
30 class TimesheetProcessorException : public std::exception
31 {
32 public:
33     explicit TimesheetProcessorException(const QString &text = QString::null)
mWhat(text)34         : mWhat(text)
35     {
36     }
37 
throw()38     ~TimesheetProcessorException() throw()
39     {
40     }
41 
what()42     const char *what() const throw()
43     {
44         return qPrintable(mWhat);
45     }
46 
47 private:
48     QString mWhat;
49 };
50 
51 class UsageException : public TimesheetProcessorException
52 {
53 public:
54     explicit UsageException(const QString &text = QString::null)
TimesheetProcessorException(text)55         : TimesheetProcessorException(text)
56     {
57     }
58 };
59 
60 #endif
61