1
/* Copyright © 2005-2006 Roger Leigh <rleigh@debian.org>
3
* schroot is free software; you can redistribute it and/or modify it
4
* under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
8
* schroot is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18
*********************************************************************/
20
#ifndef SBUILD_PARSE_ERROR_H
21
#define SBUILD_PARSE_ERROR_H
26
#include <boost/format.hpp>
28
#include "sbuild-error.h"
29
#include "sbuild-log.h"
37
class parse_error : public runtime_error
42
NONE, ///< No error occured. Used for detail only.
43
BAD_FILE, ///< The file to parse couldn't be opened.
44
BAD_VALUE, ///< The value could not be parsed.
45
INVALID_LINE, ///< The line is invalid.
46
NO_GROUP, ///< No group was specified.
47
INVALID_GROUP, ///< The group is invalid.
48
DUPLICATE_GROUP, ///< The group is a duplicate.
49
NO_KEY, ///< No key was specified.
50
DUPLICATE_KEY, ///< The key is a duplicate.
51
MISSING_KEY, ///< The key is missing.
52
DISALLOWED_KEY ///< The key is not allowed.
58
* @param error the error code.
59
* @param detail the details of the error.
61
parse_error (type error,
62
std::string const& detail);
67
* @param line the line the error occured on.
68
* @param error the error code.
69
* @param detail the details of the error.
71
parse_error (size_t line,
73
std::string const& detail);
78
* @param line the line the error occured on.
79
* @param group the group the error occured within.
80
* @param error the error code.
81
* @param detail the details of the error.
83
parse_error (size_t line,
84
std::string const& group,
86
std::string const& detail);
91
* @param line the line the error occured on.
92
* @param group the group the error occured within.
93
* @param key the key the error occured within.
94
* @param error the error code.
95
* @param detail the details of the error.
97
parse_error (size_t line,
98
std::string const& group,
99
std::string const& key,
101
std::string const& detail);
106
* @param group the group the error occured within.
107
* @param error the error code.
108
* @param detail the details of the error.
110
parse_error (std::string const& group,
112
std::string const& detail);
117
* @param group the group the error occured within.
118
* @param key the key the error occured within.
119
* @param error the error code.
120
* @param detail the details of the error.
122
parse_error (std::string const& group,
123
std::string const& key,
125
std::string const& detail);
128
/// Mapping between error code and string.
129
static std::map<type,const char *> error_strings;
132
* Get a translated error string.
134
* @param error the error code.
135
* @returns a translated error string.
138
get_error (type error);
141
* Format an error message.
143
* @param error the error code.
144
* @param detail the details of the error.
147
format_error (type error,
148
std::string const& detail);
151
* Format an error message.
153
* @param line the line the error occured on.
154
* @param error the error code.
155
* @param detail the details of the error.
158
format_error (size_t line,
160
std::string const& detail);
163
* Format an error message.
165
* @param line the line the error occured on.
166
* @param group the group the error occured within.
167
* @param error the error code.
168
* @param detail the details of the error.
171
format_error (size_t line,
172
std::string const& group,
174
std::string const& detail);
177
* Format an error message.
179
* @param line the line the error occured on.
180
* @param group the group the error occured within.
181
* @param key the key the error occured within.
182
* @param error the error code.
183
* @param detail the details of the error.
186
format_error (size_t line,
187
std::string const& group,
188
std::string const& key,
190
std::string const& detail);
193
* Format an error message.
195
* @param group the group the error occured within.
196
* @param error the error code.
197
* @param detail the details of the error.
200
format_error (std::string const& group,
202
std::string const& detail);
205
* Format an error message.
207
* @param group the group the error occured within.
208
* @param key the key the error occured within.
209
* @param error the error code.
210
* @param detail the details of the error.
213
format_error (std::string const& group,
214
std::string const& key,
216
std::string const& detail);
221
#endif /* SBUILD_PARSE_ERROR_H */