Have rbuild create the output directories
[reactos.git] / reactos / tools / rbuild / exception.cpp
1
2 #include "pch.h"
3
4 #include "rbuild.h"
5
6 using std::string;
7
8 Exception::Exception ()
9 {
10 }
11
12 Exception::Exception ( const string& message )
13 {
14 Message = message;
15 }
16
17 Exception::Exception ( const char* format,
18 ...)
19 {
20 va_list args;
21 va_start ( args,
22 format);
23 Message = ssvprintf ( format,
24 args);
25 va_end ( args );
26 }
27
28 void Exception::SetMessage ( const char* message,
29 va_list args)
30 {
31 Message = ssvprintf ( message,
32 args);
33 }
34
35
36 OutOfMemoryException::OutOfMemoryException ()
37 : Exception ( "Out of memory" )
38 {
39 }
40
41
42 InvalidOperationException::InvalidOperationException ( const char* filename,
43 const int linenumber )
44 {
45 Message = ssprintf ( "%s:%d",
46 filename,
47 linenumber );
48 }
49
50 InvalidOperationException::InvalidOperationException ( const char* filename,
51 const int linenumber,
52 const char* message,
53 ... )
54 {
55 string errorMessage;
56 va_list args;
57 va_start ( args,
58 message );
59 errorMessage = ssvprintf ( message,
60 args );
61 va_end ( args );
62 Message = ssprintf ( "%s:%d %s",
63 filename,
64 linenumber,
65 errorMessage.c_str () );
66 }
67
68
69 FileNotFoundException::FileNotFoundException ( const string& filename )
70 : Exception ( "File '%s' not found.",
71 filename.c_str() )
72 {
73 Filename = filename;
74 }
75
76
77 AccessDeniedException::AccessDeniedException ( const string& filename)
78 : Exception ( "Access denied to file or directory '%s'.",
79 filename.c_str() )
80 {
81 Filename = filename;
82 }
83
84
85 InvalidBuildFileException::InvalidBuildFileException ( const string& location,
86 const char* message,
87 ...)
88 {
89 va_list args;
90 va_start ( args,
91 message );
92 SetLocationMessage ( location, message, args );
93 va_end ( args );
94 }
95
96 InvalidBuildFileException::InvalidBuildFileException ()
97 {
98 }
99
100 void
101 InvalidBuildFileException::SetLocationMessage ( const std::string& location,
102 const char* message,
103 va_list args )
104 {
105 Message = location + ": " + ssvprintf ( message, args );
106 }
107
108 XMLSyntaxErrorException::XMLSyntaxErrorException ( const string& location,
109 const char* message,
110 ... )
111 {
112 va_list args;
113 va_start ( args,
114 message );
115 SetLocationMessage ( location, message, args );
116 va_end ( args );
117 }
118
119
120 RequiredAttributeNotFoundException::RequiredAttributeNotFoundException (
121 const string& location,
122 const string& attributeName,
123 const string& elementName )
124 : InvalidBuildFileException ( location,
125 "Required attribute '%s' not found on '%s'.",
126 attributeName.c_str (),
127 elementName.c_str ())
128 {
129 }
130
131 InvalidAttributeValueException::InvalidAttributeValueException (
132 const string& location,
133 const string& name,
134 const string& value )
135 : InvalidBuildFileException ( location,
136 "Attribute '%s' has an invalid value '%s'.",
137 name.c_str (),
138 value.c_str () )
139 {
140
141 }
142
143 BackendNameConflictException::BackendNameConflictException ( const string& name )
144 : Exception ( "Backend name conflict: '%s'",
145 name.c_str() )
146 {
147 }
148
149
150 UnknownBackendException::UnknownBackendException ( const string& name )
151 : Exception ( "Unknown Backend requested: '%s'",
152 name.c_str() )
153 {
154 }
155
156
157 UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
158 int moduletype )
159 : InvalidBuildFileException ( location,
160 "module type requested: %i",
161 moduletype )
162 {
163 }
164
165
166 InvocationFailedException::InvocationFailedException ( const std::string& command,
167 int exitcode )
168 : Exception ( "Failed to execute '%s' (exit code %d)",
169 command.c_str (),
170 exitcode )
171 {
172 Command = command;
173 ExitCode = exitcode;
174 }