Christoph_vW <Christoph@ApiViewer.de>:
[reactos.git] / reactos / tools / rbuild / exception.cpp
1 /*
2 * Copyright (C) 2005 Casper S. Hornstrup
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 #include "pch.h"
19 #include "rbuild.h"
20
21 using std::string;
22
23 Exception::Exception ()
24 {
25 }
26
27 Exception::Exception ( const string& message )
28 {
29 Message = message;
30 }
31
32 Exception::Exception ( const char* format,
33 ...)
34 {
35 va_list args;
36 va_start ( args,
37 format);
38 Message = ssvprintf ( format,
39 args);
40 va_end ( args );
41 }
42
43 void Exception::SetMessage ( const char* message,
44 va_list args)
45 {
46 Message = ssvprintf ( message,
47 args);
48 }
49
50
51 OutOfMemoryException::OutOfMemoryException ()
52 : Exception ( "Out of memory" )
53 {
54 }
55
56
57 InvalidOperationException::InvalidOperationException ( const char* filename,
58 const int linenumber )
59 {
60 Message = ssprintf ( "%s:%d",
61 filename,
62 linenumber );
63 }
64
65 InvalidOperationException::InvalidOperationException ( const char* filename,
66 const int linenumber,
67 const char* message,
68 ... )
69 {
70 string errorMessage;
71 va_list args;
72 va_start ( args,
73 message );
74 errorMessage = ssvprintf ( message,
75 args );
76 va_end ( args );
77 Message = ssprintf ( "%s:%d %s",
78 filename,
79 linenumber,
80 errorMessage.c_str () );
81 }
82
83
84 FileNotFoundException::FileNotFoundException ( const string& filename )
85 : Exception ( "File '%s' not found.",
86 filename.c_str() )
87 {
88 Filename = filename;
89 }
90
91
92 AccessDeniedException::AccessDeniedException ( const string& filename)
93 : Exception ( "Access denied to file or directory '%s'.",
94 filename.c_str() )
95 {
96 Filename = filename;
97 }
98
99
100 InvalidBuildFileException::InvalidBuildFileException ( const string& location,
101 const char* message,
102 ...)
103 {
104 va_list args;
105 va_start ( args,
106 message );
107 SetLocationMessage ( location, message, args );
108 va_end ( args );
109 }
110
111 InvalidBuildFileException::InvalidBuildFileException ()
112 {
113 }
114
115 void
116 InvalidBuildFileException::SetLocationMessage ( const std::string& location,
117 const char* message,
118 va_list args )
119 {
120 Message = location + ": " + ssvprintf ( message, args );
121 }
122
123 XMLSyntaxErrorException::XMLSyntaxErrorException ( const string& location,
124 const char* message,
125 ... )
126 {
127 va_list args;
128 va_start ( args,
129 message );
130 SetLocationMessage ( location, message, args );
131 va_end ( args );
132 }
133
134
135 RequiredAttributeNotFoundException::RequiredAttributeNotFoundException (
136 const string& location,
137 const string& attributeName,
138 const string& elementName )
139 : InvalidBuildFileException ( location,
140 "Required attribute '%s' not found on '%s'.",
141 attributeName.c_str (),
142 elementName.c_str ())
143 {
144 }
145
146 InvalidAttributeValueException::InvalidAttributeValueException (
147 const string& location,
148 const string& name,
149 const string& value )
150 : InvalidBuildFileException ( location,
151 "Attribute '%s' has an invalid value '%s'.",
152 name.c_str (),
153 value.c_str () )
154 {
155
156 }
157
158 BackendNameConflictException::BackendNameConflictException ( const string& name )
159 : Exception ( "Backend name conflict: '%s'",
160 name.c_str() )
161 {
162 }
163
164
165 UnknownBackendException::UnknownBackendException ( const string& name )
166 : Exception ( "Unknown Backend requested: '%s'",
167 name.c_str() )
168 {
169 }
170
171
172 UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
173 int moduletype )
174 : InvalidBuildFileException ( location,
175 "module type requested: %i",
176 moduletype )
177 {
178 }
179
180
181 InvocationFailedException::InvocationFailedException ( const std::string& command,
182 int exitcode )
183 : Exception ( "Failed to execute '%s' (exit code %d)",
184 command.c_str (),
185 exitcode )
186 {
187 Command = command;
188 ExitCode = exitcode;
189 }
190
191
192 UnsupportedBuildToolException::UnsupportedBuildToolException ( const std::string& buildTool,
193 const std::string& version )
194 : Exception ( "Build tool '%s' with version '%s' is unsupported. Please upgrade your build tool.",
195 buildTool.c_str (),
196 version.c_str () )
197 {
198 BuildTool = buildTool;
199 Version = version;
200 }