798773aacf0c871739e714f3ebe13b99b30c27a9
[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 InvalidOperationException::InvalidOperationException ( const char* filename,
37 const int linenumber)
38 {
39 Message = ssprintf ( "%s:%d",
40 filename,
41 linenumber );
42 }
43
44
45 FileNotFoundException::FileNotFoundException ( const string& filename )
46 : Exception ( "File '%s' not found.",
47 filename.c_str() )
48 {
49 Filename = filename;
50 }
51
52
53 AccessDeniedException::AccessDeniedException ( const string& filename)
54 : Exception ( "Access denied to file '%s'.",
55 filename.c_str() )
56 {
57 Filename = filename;
58 }
59
60
61 InvalidBuildFileException::InvalidBuildFileException ( const string& location,
62 const char* message,
63 ...)
64 {
65 va_list args;
66 va_start ( args,
67 message );
68 SetLocationMessage ( location, message, args );
69 va_end ( args );
70 }
71
72 InvalidBuildFileException::InvalidBuildFileException ()
73 {
74 }
75
76 void
77 InvalidBuildFileException::SetLocationMessage ( const std::string& location,
78 const char* message,
79 va_list args )
80 {
81 Message = location + ": " + ssvprintf ( message, args );
82 }
83
84 XMLSyntaxErrorException::XMLSyntaxErrorException ( const string& location,
85 const char* message,
86 ... )
87 {
88 va_list args;
89 va_start ( args,
90 message );
91 SetLocationMessage ( location, message, args );
92 va_end ( args );
93 }
94
95
96 RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( const string& attributeName,
97 const string& elementName )
98 : InvalidBuildFileException ( "Required attribute '%s' not found on '%s'.",
99 attributeName.c_str (),
100 elementName.c_str ())
101 {
102 }
103
104 InvalidAttributeValueException::InvalidAttributeValueException ( const string& name,
105 const string& value )
106 : InvalidBuildFileException ( "Attribute '%s' has an invalid value '%s'.",
107 name.c_str (),
108 value.c_str () )
109 {
110
111 }
112
113 BackendNameConflictException::BackendNameConflictException ( const string& name )
114 : Exception ( "Backend name conflict: '%s'",
115 name.c_str() )
116 {
117 }
118
119
120 UnknownBackendException::UnknownBackendException ( const string& name )
121 : Exception ( "Unknown Backend requested: '%s'",
122 name.c_str() )
123 {
124 }
125
126 UnknownModuleTypeException::UnknownModuleTypeException ( const string& moduletype )
127 : Exception ( "module type requested: '%s'",
128 moduletype.c_str() )
129 {
130 }