Fawkes API  Fawkes Development Version
exceptions.h
1 
2 /***************************************************************************
3  * exceptions.h - Interface generator exceptions
4  *
5  * Generated: Tue Oct 10 18:11:59 2006
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __INTERFACES_GENERATOR_EXCEPTIONS_H_
24 #define __INTERFACES_GENERATOR_EXCEPTIONS_H_
25 
26 #include <core/exception.h>
27 
28 /** Thrown if document was invalid.
29  * This may happen if the document is not well-formed or if the file does not
30  * exist.
31  */
33  public:
34  /** Constructor
35  * @param format message format string, followed by the appropriate number of
36  * arguments. Cf. printf man page for valid format.
37  */
39  : fawkes::Exception()
40  {
41  va_list arg;
42  va_start(arg, format);
43  append_va(format, arg);
44  va_end(arg);
45  }
46 };
47 
48 /** Thrown if document contains illegal content.
49  * This happens if there was content in the file which was while syntactically correct
50  * semantically wrong. Examples for this are more than one data segment or no one at all.
51  */
53  public:
54  /** Constructor
55  * @param format message format string, followed by the appropriate number of
56  * arguments. Cf. printf man page for valid format.
57  */
59  : fawkes::Exception()
60  {
61  va_list arg;
62  va_start(arg, format);
63  append_va(format, arg);
64  va_end(arg);
65  }
66 };
67 
68 
69 /** Thrown if illegal type is supplied.
70  * Only a few basic types are allowed. If a typo occured or an unknown type was used
71  * this exception is thrown.
72  */
74  public:
75  /** Constructor
76  * @param item item type
77  * @param name item name
78  * @param type invalid data type
79  */
80  InterfaceGeneratorInvalidTypeException(const char *item, const char *name, const char *type)
81  : fawkes::Exception()
82  {
83  append("Invalid type for %s item '%s': %s", item, name, type);
84  }
85 };
86 
87 /** Thrown if illegal value is supplied.
88  * Thrown if wrong value was supplied for a given value
89  */
91  public:
92  /** Constructor
93  * @param name item name
94  * @param type data type
95  * @param value invalid value
96  */
97  InterfaceGeneratorInvalidValueException(const char *name, const char *type, const char *value)
98  : fawkes::Exception()
99  {
100  append("Invalid value for '%s' of type %s: %s", name, type, value);
101  }
102 };
103 
104 /** Thrown if illegal attribute is supplied.
105  * Thrown if illegal attribute was supplied for a given value
106  */
108  public:
109  /** Constructor
110  * @param name item name
111  * @param type data type
112  * @param attr invalid attribute
113  */
114  InterfaceGeneratorInvalidAttributeException(const char *name, const char *type, const char *attr)
115  : fawkes::Exception()
116  {
117  append("Attribute '%s' may not be specified for '%s' of type %s", attr, name, type);
118  }
119 };
120 
121 
122 /** Thrown if illegal flag is supplied.
123  * Thrown if illegal flag was supplied for a given value
124  */
126  public:
127  /** Constructor
128  * @param name item name
129  * @param flag invalid flag
130  */
131  InterfaceGeneratorInvalidFlagException(const char *name, const char *flag)
132  : fawkes::Exception()
133  {
134  append("Illegal flag '%s' set for %s", flag, name);
135  }
136 };
137 
138 
139 /** Thrown if required attribute is missing supplied.
140  * Thrown if required attribute was not supplied for a given value
141  */
143  public:
144  /** Constructor
145  * @param name item name
146  * @param type data type
147  * @param attr missing attribute
148  */
149  InterfaceGeneratorMissingAttributeException(const char *name, const char *type, const char *attr)
150  : fawkes::Exception()
151  {
152  append("Attribute '%s' is required '%s' of type %s", attr, name, type);
153  }
154 };
155 
156 
157 /** Thrown if name is ambiguous. */
159  public:
160  /** Constructor
161  * @param name ambiguous name
162  * @param item item type
163  */
164  InterfaceGeneratorAmbiguousNameException(const char *name, const char *item)
165  : fawkes::Exception()
166  {
167  append("There are multiple %s items with name '%s'", item, name);
168  }
169 };
170 
171 
172 #endif
Thrown if document contains illegal content.
Definition: exceptions.h:52
Fawkes library namespace.
Exception()
Constructor for subclasses.
Definition: exception.cpp:257
InterfaceGeneratorMissingAttributeException(const char *name, const char *type, const char *attr)
Constructor.
Definition: exceptions.h:149
InterfaceGeneratorInvalidContentException(const char *format,...)
Constructor.
Definition: exceptions.h:58
InterfaceGeneratorInvalidValueException(const char *name, const char *type, const char *value)
Constructor.
Definition: exceptions.h:97
Thrown if illegal value is supplied.
Definition: exceptions.h:90
Base class for exceptions in Fawkes.
Definition: exception.h:36
Thrown if required attribute is missing supplied.
Definition: exceptions.h:142
Thrown if name is ambiguous.
Definition: exceptions.h:158
InterfaceGeneratorInvalidTypeException(const char *item, const char *name, const char *type)
Constructor.
Definition: exceptions.h:80
InterfaceGeneratorInvalidDocumentException(const char *format,...)
Constructor.
Definition: exceptions.h:38
void append_va(const char *format, va_list va)
Append messages to the message list.
Definition: exception.cpp:361
Thrown if document was invalid.
Definition: exceptions.h:32
Thrown if illegal flag is supplied.
Definition: exceptions.h:125
InterfaceGeneratorInvalidAttributeException(const char *name, const char *type, const char *attr)
Constructor.
Definition: exceptions.h:114
InterfaceGeneratorInvalidFlagException(const char *name, const char *flag)
Constructor.
Definition: exceptions.h:131
Thrown if illegal attribute is supplied.
Definition: exceptions.h:107
InterfaceGeneratorAmbiguousNameException(const char *name, const char *item)
Constructor.
Definition: exceptions.h:164
void append(const char *format,...)
Append messages to the message list.
Definition: exception.cpp:341
Thrown if illegal type is supplied.
Definition: exceptions.h:73