~ubuntu-branches/ubuntu/intrepid/schroot/intrepid

« back to all changes in this revision

Viewing changes to schroot/sbuild-parse-error.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2006-06-28 20:40:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060628204013-y6spuk42okis0snx
Tags: 0.99.0-1ubuntu1
* remerge ubuntu changes:
  + debian/control: libpam-dev (>> 0.79-3ubuntu6)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright © 2005-2006  Roger Leigh <rleigh@debian.org>
 
2
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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,
 
16
 * MA  02111-1307  USA
 
17
 *
 
18
 *********************************************************************/
 
19
 
 
20
#ifndef SBUILD_PARSE_ERROR_H
 
21
#define SBUILD_PARSE_ERROR_H
 
22
 
 
23
#include <map>
 
24
#include <string>
 
25
 
 
26
#include <boost/format.hpp>
 
27
 
 
28
#include "sbuild-error.h"
 
29
#include "sbuild-log.h"
 
30
 
 
31
namespace sbuild
 
32
{
 
33
 
 
34
  /**
 
35
   * Parse error.
 
36
   */
 
37
  class parse_error : public runtime_error
 
38
  {
 
39
  public:
 
40
    enum type
 
41
      {
 
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.
 
53
      };
 
54
 
 
55
    /**
 
56
     * The constructor.
 
57
     *
 
58
     * @param error the error code.
 
59
     * @param detail the details of the error.
 
60
     */
 
61
    parse_error (type               error,
 
62
                 std::string const& detail);
 
63
 
 
64
    /**
 
65
     * The constructor.
 
66
     *
 
67
     * @param line the line the error occured on.
 
68
     * @param error the error code.
 
69
     * @param detail the details of the error.
 
70
     */
 
71
    parse_error (size_t             line,
 
72
                 type               error,
 
73
                 std::string const& detail);
 
74
 
 
75
    /**
 
76
     * The constructor.
 
77
     *
 
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.
 
82
     */
 
83
    parse_error (size_t             line,
 
84
                 std::string const& group,
 
85
                 type               error,
 
86
                 std::string const& detail);
 
87
 
 
88
    /**
 
89
     * The constructor.
 
90
     *
 
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.
 
96
     */
 
97
    parse_error (size_t             line,
 
98
                 std::string const& group,
 
99
                 std::string const& key,
 
100
                 type               error,
 
101
                 std::string const& detail);
 
102
 
 
103
    /**
 
104
     * The constructor.
 
105
     *
 
106
     * @param group the group the error occured within.
 
107
     * @param error the error code.
 
108
     * @param detail the details of the error.
 
109
     */
 
110
    parse_error (std::string const& group,
 
111
                 type               error,
 
112
                 std::string const& detail);
 
113
 
 
114
    /**
 
115
     * The constructor.
 
116
     *
 
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.
 
121
     */
 
122
    parse_error (std::string const& group,
 
123
                 std::string const& key,
 
124
                 type               error,
 
125
                 std::string const& detail);
 
126
 
 
127
  private:
 
128
    /// Mapping between error code and string.
 
129
    static std::map<type,const char *> error_strings;
 
130
 
 
131
    /**
 
132
     * Get a translated error string.
 
133
     *
 
134
     * @param error the error code.
 
135
     * @returns a translated error string.
 
136
     */
 
137
    static const char *
 
138
    get_error (type error);
 
139
 
 
140
    /**
 
141
     * Format an error message.
 
142
     *
 
143
     * @param error the error code.
 
144
     * @param detail the details of the error.
 
145
     */
 
146
    static std::string
 
147
    format_error (type               error,
 
148
                  std::string const& detail);
 
149
 
 
150
    /**
 
151
     * Format an error message.
 
152
     *
 
153
     * @param line the line the error occured on.
 
154
     * @param error the error code.
 
155
     * @param detail the details of the error.
 
156
     */
 
157
    static std::string
 
158
    format_error (size_t             line,
 
159
                  type               error,
 
160
                  std::string const& detail);
 
161
 
 
162
    /**
 
163
     * Format an error message.
 
164
     *
 
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.
 
169
     */
 
170
    static std::string
 
171
    format_error (size_t             line,
 
172
                  std::string const& group,
 
173
                  type               error,
 
174
                  std::string const& detail);
 
175
 
 
176
    /**
 
177
     * Format an error message.
 
178
     *
 
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.
 
184
     */
 
185
    static std::string
 
186
    format_error (size_t             line,
 
187
                  std::string const& group,
 
188
                  std::string const& key,
 
189
                  type               error,
 
190
                  std::string const& detail);
 
191
 
 
192
    /**
 
193
     * Format an error message.
 
194
     *
 
195
     * @param group the group the error occured within.
 
196
     * @param error the error code.
 
197
     * @param detail the details of the error.
 
198
     */
 
199
    static std::string
 
200
    format_error (std::string const& group,
 
201
                  type               error,
 
202
                  std::string const& detail);
 
203
 
 
204
    /**
 
205
     * Format an error message.
 
206
     *
 
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.
 
211
     */
 
212
    static std::string
 
213
    format_error (std::string const& group,
 
214
                  std::string const& key,
 
215
                  type               error,
 
216
                  std::string const& detail);
 
217
  };
 
218
 
 
219
}
 
220
 
 
221
#endif /* SBUILD_PARSE_ERROR_H */
 
222
 
 
223
/*
 
224
 * Local Variables:
 
225
 * mode:C++
 
226
 * End:
 
227
 */