don't use VCToolsFile anymore because of different include dirs for subprojects
[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 _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 OutOfMemoryException::OutOfMemoryException ()
55 : Exception ( "Out of memory" )
56 {
57 }
58
59
60 InvalidOperationException::InvalidOperationException (
61 const char* filename,
62 const int linenumber )
63 : Exception ( "%s:%d", filename, linenumber )
64 {
65 }
66
67 InvalidOperationException::InvalidOperationException (
68 const char* filename,
69 const int linenumber,
70 const char* message,
71 ... )
72 {
73 string errorMessage;
74 va_list args;
75 va_start ( args, message );
76 errorMessage = ssvprintf ( message, args );
77 va_end ( args );
78 SetMessage (
79 "%s:%d %s",
80 filename,
81 linenumber,
82 errorMessage.c_str () );
83 }
84
85
86 FileNotFoundException::FileNotFoundException ( const string& filename )
87 : Exception ( "File '%s' not found.",
88 filename.c_str() )
89 {
90 Filename = filename;
91 }
92
93
94 AccessDeniedException::AccessDeniedException ( const string& filename)
95 : Exception ( "Access denied to file or directory '%s'.",
96 filename.c_str() )
97 {
98 Filename = filename;
99 }
100
101
102 RequiredAttributeNotFoundException::RequiredAttributeNotFoundException (
103 const string& location,
104 const string& attributeName,
105 const string& elementName )
106 : XMLInvalidBuildFileException (
107 location,
108 "Required attribute '%s' not found on '%s'.",
109 attributeName.c_str (),
110 elementName.c_str ())
111 {
112 }
113
114 InvalidAttributeValueException::InvalidAttributeValueException (
115 const string& location,
116 const string& name,
117 const string& value )
118 : XMLInvalidBuildFileException (
119 location,
120 "Attribute '%s' has an invalid value '%s'.",
121 name.c_str (),
122 value.c_str () )
123 {
124
125 }
126
127 BackendNameConflictException::BackendNameConflictException ( const string& name )
128 : Exception ( "Backend name conflict: '%s'",
129 name.c_str() )
130 {
131 }
132
133
134 UnknownBackendException::UnknownBackendException ( const string& name )
135 : Exception ( "Unknown Backend requested: '%s'",
136 name.c_str() )
137 {
138 }
139
140
141 UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
142 int moduletype )
143 : XMLInvalidBuildFileException (
144 location,
145 "module type requested: %i",
146 moduletype )
147 {
148 }
149
150
151 InvocationFailedException::InvocationFailedException ( const std::string& command,
152 int exitcode )
153 : Exception ( "Failed to execute '%s' (exit code %d)",
154 command.c_str (),
155 exitcode )
156 {
157 Command = command;
158 ExitCode = exitcode;
159 }
160
161
162 UnsupportedBuildToolException::UnsupportedBuildToolException ( const std::string& buildTool,
163 const std::string& version )
164 : Exception ( "Build tool '%s' with version '%s' is unsupported. Please upgrade your build tool.",
165 buildTool.c_str (),
166 version.c_str () )
167 {
168 BuildTool = buildTool;
169 Version = version;
170 }