* Bring back rbuild build to be used until bug 6372 is fixed.
[reactos.git] / 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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 _e = message;
30 }
31
32 Exception::Exception ( const char* format, ...)
33 {
34 va_list args;
35 va_start ( args, format);
36 _e = ssvprintf ( format, args);
37 va_end ( args );
38 }
39
40 void Exception::SetMessage ( const char* format, ...)
41 {
42 va_list args;
43 va_start ( args, format);
44 _e = ssvprintf ( format, args);
45 va_end ( args );
46 }
47
48 void Exception::SetMessageV ( const char* message, va_list args )
49 {
50 _e = ssvprintf ( message, args);
51 }
52
53
54 MissingArgumentException::MissingArgumentException ( const string& argument )
55 : Exception ( "Argument '%s' is missing",
56 argument.c_str () )
57 {
58 }
59
60
61 OutOfMemoryException::OutOfMemoryException ()
62 : Exception ( "Out of memory" )
63 {
64 }
65
66
67 InvalidOperationException::InvalidOperationException (
68 const char* filename,
69 const int linenumber )
70 : Exception ( "%s:%d", filename, linenumber )
71 {
72 }
73
74 InvalidDateException::InvalidDateException ( const string& filename)
75 : Exception ( "File '%s' has an invalid date.",
76 filename.c_str() )
77 {
78 Filename = filename;
79 }
80
81 InvalidOperationException::InvalidOperationException (
82 const char* filename,
83 const int linenumber,
84 const char* message,
85 ... )
86 {
87 string errorMessage;
88 va_list args;
89 va_start ( args, message );
90 errorMessage = ssvprintf ( message, args );
91 va_end ( args );
92 SetMessage (
93 "%s:%d %s",
94 filename,
95 linenumber,
96 errorMessage.c_str () );
97 }
98
99
100 FileNotFoundException::FileNotFoundException ( const string& filename )
101 : Exception ( "File '%s' not found.",
102 filename.c_str() )
103 {
104 Filename = filename;
105 }
106
107
108 AccessDeniedException::AccessDeniedException ( const string& filename)
109 : Exception ( "Access denied to file or directory '%s'.",
110 filename.c_str() )
111 {
112 Filename = filename;
113 }
114
115
116 RequiredAttributeNotFoundException::RequiredAttributeNotFoundException (
117 const string& location,
118 const string& attributeName,
119 const string& elementName )
120 : XMLInvalidBuildFileException (
121 location,
122 "Required attribute '%s' not found on '%s'.",
123 attributeName.c_str (),
124 elementName.c_str ())
125 {
126 }
127
128 InvalidAttributeValueException::InvalidAttributeValueException (
129 const string& location,
130 const string& name,
131 const string& value )
132 : XMLInvalidBuildFileException (
133 location,
134 "Attribute '%s' has an invalid value '%s'.",
135 name.c_str (),
136 value.c_str () )
137 {
138
139 }
140
141 BackendNameConflictException::BackendNameConflictException ( const string& name )
142 : Exception ( "Backend name conflict: '%s'",
143 name.c_str() )
144 {
145 }
146
147
148 UnknownBackendException::UnknownBackendException ( const string& name )
149 : Exception ( "Unknown Backend requested: '%s'",
150 name.c_str() )
151 {
152 }
153
154
155 UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
156 int moduletype )
157 : XMLInvalidBuildFileException (
158 location,
159 "module type requested: %i",
160 moduletype )
161 {
162 }
163
164
165 InvocationFailedException::InvocationFailedException ( const std::string& command,
166 int exitcode )
167 : Exception ( "Failed to execute '%s' (exit code %d)",
168 command.c_str (),
169 exitcode )
170 {
171 Command = command;
172 ExitCode = exitcode;
173 }
174
175
176 UnsupportedBuildToolException::UnsupportedBuildToolException ( const std::string& buildTool,
177 const std::string& version )
178 : Exception ( "Build tool '%s' with version '%s' is unsupported. Please upgrade your build tool.",
179 buildTool.c_str (),
180 version.c_str () )
181 {
182 BuildTool = buildTool;
183 Version = version;
184 }