odsstream
Loading...
Searching...
No Matches
odsexception.h
1/*
2 libodsstream is a library to read and write ODS documents as streams
3 Copyright (C) 2013 Olivier Langella <Olivier.Langella@moulon.inra.fr>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18*/
19
20#pragma once
21
22#include <QException>
23#include <QDebug>
24
25
26class OdsException : public QException
27{
28 public:
29 OdsException(const QString &message) throw()
30 {
31 qDebug() << message;
32 m_message = message;
33 m_stdMessage.assign(m_message.toStdString());
34 }
35
36 OdsException(const OdsException &other) throw()
37 {
38 m_message = other.m_message;
39 m_stdMessage.assign(m_message.toStdString());
40 }
41 void
42 raise() const override
43 {
44 throw *this;
45 }
46 virtual QException *
47 clone() const override
48 {
49 return new OdsException(*this);
50 }
51
52 virtual const QString &
53 qwhat() const throw()
54 {
55 return m_message;
56 }
57
58 const char *
59 what() const noexcept override
60 {
61 return m_stdMessage.c_str();
62 }
63
64 virtual ~OdsException() throw()
65 {
66 }
67
68 private:
69 std::string m_stdMessage;
70 QString m_message; // Description of the error
71};
Definition odsexception.h:27