paludis
Version 2.6.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
paludis
util
exception.hh
Go to the documentation of this file.
1
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3
/*
4
* Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
5
*
6
* This file is part of the Paludis package manager. Paludis is free software;
7
* you can redistribute it and/or modify it under the terms of the GNU General
8
* Public License version 2, as published by the Free Software Foundation.
9
*
10
* Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
* details.
14
*
15
* You should have received a copy of the GNU General Public License along with
16
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17
* Place, Suite 330, Boston, MA 02111-1307 USA
18
*/
19
20
#ifndef PALUDIS_GUARD_PALUDIS_EXCEPTION_HH
21
#define PALUDIS_GUARD_PALUDIS_EXCEPTION_HH 1
22
23
#include <
paludis/util/attributes.hh
>
24
#include <string>
25
#include <exception>
26
27
/** \file
28
* Declaration for the Exception base class, the InternalError exception
29
* class, the NameError class and related utilities.
30
*
31
* \ingroup g_exceptions
32
*
33
* \section Examples
34
*
35
* - None at this time.
36
*/
37
38
namespace
paludis
39
{
40
/**
41
* Backtrace context class.
42
*
43
* \ingroup g_exceptions
44
* \nosubgrouping
45
*/
46
class
PALUDIS_VISIBLE
Context
47
{
48
private
:
49
Context
(
const
Context
&);
50
const
Context
& operator= (
const
Context
&);
51
52
public
:
53
///\name Basic operations
54
///\{
55
56
Context
(
const
std::string &);
57
58
~
Context
() noexcept(
false
);
59
60
///\}
61
62
/**
63
* Current context.
64
*/
65
static
std::string backtrace(
const
std::string & delim);
66
};
67
68
/**
69
* Base exception class.
70
*
71
* \ingroup g_exceptions
72
* \nosubgrouping
73
*/
74
class
PALUDIS_VISIBLE
Exception
:
75
public
std::exception
76
{
77
private
:
78
const
std::string _message;
79
mutable
std::string _what_str;
80
struct
ContextData;
81
ContextData *
const
_context_data;
82
83
const
Exception
& operator= (
const
Exception
&);
84
85
protected
:
86
///\name Basic operations
87
///\{
88
89
Exception
(
const
std::string & message) noexcept;
90
91
Exception
(
const
Exception
&);
92
93
///\}
94
95
public
:
96
///\name Basic operations
97
///\{
98
99
virtual
~
Exception
();
100
101
///\}
102
103
/**
104
* Return our descriptive error message.
105
*/
106
const
std::string & message()
const
noexcept;
107
108
/**
109
* Make a backtrace.
110
*/
111
std::string backtrace(
const
std::string & delim)
const
;
112
113
/**
114
* Is our backtrace empty?
115
*/
116
bool
empty()
const
;
117
118
/**
119
* A better what, if possible.
120
*/
121
const
char
* what()
const
noexcept;
122
};
123
124
/**
125
* An InternalError is an Exception that is thrown if something that is
126
* never supposed to happen happens.
127
*
128
* \ingroup g_exceptions
129
* \nosubgrouping
130
*/
131
class
PALUDIS_VISIBLE
InternalError
:
132
public
Exception
133
{
134
public
:
135
/**
136
* Constructor.
137
*
138
* \param location Should be set to the PALUDIS_HERE macro.
139
*
140
* \param message A short message.
141
*/
142
InternalError
(
const
std::string & location,
const
std::string & message) noexcept;
143
};
144
145
/**
146
* A NotAvailableError is an Exception that is thrown if something that is
147
* not available (for example due to compile time configure options or platform
148
* limitations) is used.
149
*
150
* \ingroup g_exceptions
151
* \nosubgrouping
152
*/
153
class
PALUDIS_VISIBLE
NotAvailableError
:
154
public
Exception
155
{
156
public
:
157
/**
158
* Constructor.
159
*/
160
NotAvailableError
(
const
std::string & message) noexcept;
161
};
162
163
/**
164
* A NameError is an Exception that is thrown when some kind of invalid
165
* name is encountered.
166
*
167
* \ingroup g_exceptions
168
* \ingroup g_names
169
* \nosubgrouping
170
*/
171
class
PALUDIS_VISIBLE
NameError
:
172
public
Exception
173
{
174
protected
:
175
/**
176
* Constructor.
177
*
178
* \param name The invalid name encountered.
179
* \param role The role for the name, for example "package name".
180
*/
181
NameError
(
const
std::string & name,
const
std::string & role) noexcept;
182
183
/**
184
* Constructor.
185
*
186
* \param name The invalid name encountered.
187
* \param role The role for the name, for example "package name".
188
* \param msg Any extra message.
189
*/
190
NameError
(
const
std::string & name,
const
std::string & role,
191
const
std::string & msg) noexcept;
192
};
193
194
/**
195
* A ConfigurationError is thrown when an invalid configuration occurs.
196
*
197
* \ingroup g_exceptions
198
* \nosubgrouping
199
*/
200
class
PALUDIS_VISIBLE
ConfigurationError
:
201
public
Exception
202
{
203
public
:
204
/**
205
* Constructor.
206
*/
207
ConfigurationError
(
const
std::string & msg) noexcept;
208
};
209
210
/** \def PALUDIS_HERE
211
* Expands to the current function name, file and line, for use with
212
* paludis::InternalError.
213
*
214
* \ingroup g_exceptions
215
*/
216
#define PALUDIS_HERE (std::string(__PRETTY_FUNCTION__) + " at " + \
217
std::string(__FILE__) + ":" + paludis::stringify(__LINE__))
218
}
219
220
#endif
paludis
Definition:
about_metadata-fwd.hh:23
paludis::Context
Definition:
exception.hh:46
paludis::InternalError
Definition:
exception.hh:131
paludis::NameError
Definition:
exception.hh:171
paludis::NotAvailableError
Definition:
exception.hh:153
paludis::Exception
Definition:
exception.hh:74
attributes.hh
paludis::ConfigurationError
Definition:
exception.hh:200
PALUDIS_VISIBLE
#define PALUDIS_VISIBLE
Definition:
attributes.hh:59
Generated by
1.8.11