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