Alkimia API

alkexception.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2000-2018 Thomas Baumgart tbaumgart @kde.org
3
4 This file is part of libalkimia.
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#ifndef ALKEXCEPTION_H
10#define ALKEXCEPTION_H
11
12#include <alkimia/alk_export.h>
13
14#include <QString>
15
16/**
17 * @file
18 * @author Thomas Baumgart
19 */
20
21/**
22 * This class describes an exception that is thrown by the engine
23 * in case of a failure.
24 */
25class ALK_NO_EXPORT AlkException
26{
27public:
28 /**
29 * @def ALKEXCEPTION(text)
30 * This is the preferred constructor to create a new exception
31 * object. It automatically inserts the filename and the source
32 * code line into the object upon creation.
33 *
34 * It is equivalent to AlkException(text, __FILE__, __LINE__)
35 */
36#define ALKEXCEPTION(what) AlkException(what, __FILE__, __LINE__)
37
38 /**
39 * The constructor to create a new ALKEXCEPTION object.
40 *
41 * @param msg reference to QString containing the message
42 * @param file reference to QString containing the name of the sourcefile where
43 * the exception was thrown
44 * @param line unsigned long containing the line number of the line where
45 * the exception was thrown in the file.
46 *
47 * An easier way to use this constructor is to use the macro
48 * ALKEXCEPTION(text) instead. It automatically assigns the file
49 * and line parameter to the correct values.
50 */
51 AlkException(const QString &msg, const QString &file, const unsigned long line);
52
54
55 /**
56 * This method is used to return the message that was passed
57 * during the creation of the exception object.
58 *
59 * @return reference to QString containing the message
60 */
61 const QString &what() const
62 {
63 return m_msg;
64 }
65
66 /**
67 * This method is used to return the filename that was passed
68 * during the creation of the exception object.
69 *
70 * @return reference to QString containing the filename
71 */
72 const QString &file() const
73 {
74 return m_file;
75 }
76
77 /**
78 * This method is used to return the linenumber that was passed
79 * during the creation of the exception object.
80 *
81 * @return long integer containing the line number
82 */
83 unsigned long line() const
84 {
85 return m_line;
86 }
87
88private:
89 /**
90 * This member variable holds the message
91 */
92 QString m_msg;
93
94 /**
95 * This member variable holds the filename
96 */
97 QString m_file;
98
99 /**
100 * This member variable holds the line number
101 */
102 unsigned long m_line;
103};
104
105#endif
This class describes an exception that is thrown by the engine in case of a failure.
const QString & what() const
This method is used to return the message that was passed during the creation of the exception object...
const QString & file() const
This method is used to return the filename that was passed during the creation of the exception objec...
unsigned long line() const
This method is used to return the linenumber that was passed during the creation of the exception obj...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.