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 {
34 public:
35  /** Constructor
36  * @param format message format string, followed by the appropriate number of
37  * arguments. Cf. printf man page for valid format.
38  */
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 {
54 public:
55  /** Constructor
56  * @param format message format string, followed by the appropriate number of
57  * arguments. Cf. printf man page for valid format.
58  */
60  {
61  va_list arg;
62  va_start(arg, format);
63  append_va(format, arg);
64  va_end(arg);
65  }
66 };
67 
68 /** Thrown if illegal type is supplied.
69  * Only a few basic types are allowed. If a typo occured or an unknown type was used
70  * this exception is thrown.
71  */
73 {
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 {
92 public:
93  /** Constructor
94  * @param name item name
95  * @param type data type
96  * @param value invalid value
97  */
98  InterfaceGeneratorInvalidValueException(const char *name, const char *type, const char *value)
99  : fawkes::Exception()
100  {
101  append("Invalid value for '%s' of type %s: %s", name, type, value);
102  }
103 };
104 
105 /** Thrown if illegal attribute is supplied.
106  * Thrown if illegal attribute was supplied for a given value
107  */
109 {
110 public:
111  /** Constructor
112  * @param name item name
113  * @param type data type
114  * @param attr invalid attribute
115  */
116  InterfaceGeneratorInvalidAttributeException(const char *name, const char *type, const char *attr)
117  : fawkes::Exception()
118  {
119  append("Attribute '%s' may not be specified for '%s' of type %s", attr, name, type);
120  }
121 };
122 
123 /** Thrown if illegal flag is supplied.
124  * Thrown if illegal flag was supplied for a given value
125  */
127 {
128 public:
129  /** Constructor
130  * @param name item name
131  * @param flag invalid flag
132  */
133  InterfaceGeneratorInvalidFlagException(const char *name, const char *flag) : fawkes::Exception()
134  {
135  append("Illegal flag '%s' set for %s", flag, name);
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 {
144 public:
145  /** Constructor
146  * @param name item name
147  * @param type data type
148  * @param attr missing attribute
149  */
150  InterfaceGeneratorMissingAttributeException(const char *name, const char *type, const char *attr)
151  : fawkes::Exception()
152  {
153  append("Attribute '%s' is required '%s' of type %s", attr, name, type);
154  }
155 };
156 
157 /** Thrown if name is ambiguous. */
159 {
160 public:
161  /** Constructor
162  * @param name ambiguous name
163  * @param item item type
164  */
165  InterfaceGeneratorAmbiguousNameException(const char *name, const char *item) : fawkes::Exception()
166  {
167  append("There are multiple %s items with name '%s'", item, name);
168  }
169 };
170 
171 /** Thrown if something is a reserved identifier. */
173 {
174 public:
175  /**
176  * @brief InterfaceGeneratorReservedIdentifierException
177  * @param item type of offending item
178  * @param name Offending name
179  */
180  InterfaceGeneratorReservedIdentifierException(const char *item, const char *name)
181  : fawkes::Exception()
182  {
183  append("%s name '%s' is a reserved identifier", item, name);
184  }
185 };
186 
187 #endif
Thrown if document contains illegal content.
Definition: exceptions.h:52
Fawkes library namespace.
Exception()
Constructor for subclasses.
Definition: exception.cpp:253
InterfaceGeneratorMissingAttributeException(const char *name, const char *type, const char *attr)
Constructor.
Definition: exceptions.h:150
InterfaceGeneratorInvalidContentException(const char *format,...)
Constructor.
Definition: exceptions.h:59
InterfaceGeneratorInvalidValueException(const char *name, const char *type, const char *value)
Constructor.
Definition: exceptions.h:98
Thrown if illegal value is supplied.
Definition: exceptions.h:90
Base class for exceptions in Fawkes.
Definition: exception.h:35
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:39
void append_va(const char *format, va_list va)
Append messages to the message list.
Definition: exception.cpp:353
InterfaceGeneratorReservedIdentifierException(const char *item, const char *name)
InterfaceGeneratorReservedIdentifierException.
Definition: exceptions.h:180
Thrown if document was invalid.
Definition: exceptions.h:32
Thrown if illegal flag is supplied.
Definition: exceptions.h:126
InterfaceGeneratorInvalidAttributeException(const char *name, const char *type, const char *attr)
Constructor.
Definition: exceptions.h:116
InterfaceGeneratorInvalidFlagException(const char *name, const char *flag)
Constructor.
Definition: exceptions.h:133
Thrown if illegal attribute is supplied.
Definition: exceptions.h:108
InterfaceGeneratorAmbiguousNameException(const char *name, const char *item)
Constructor.
Definition: exceptions.h:165
void append(const char *format,...)
Append messages to the message list.
Definition: exception.cpp:333
Thrown if illegal type is supplied.
Definition: exceptions.h:72
Thrown if something is a reserved identifier.
Definition: exceptions.h:172