1 // Copyright 2012 The Kyua Authors.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 //   notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 //   notice, this list of conditions and the following disclaimer in the
12 //   documentation and/or other materials provided with the distribution.
13 // * Neither the name of Google Inc. nor the names of its contributors
14 //   may be used to endorse or promote products derived from this software
15 //   without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 #include "utils/config/exceptions.hpp"
30 
31 #include "utils/config/tree.ipp"
32 #include "utils/format/macros.hpp"
33 
34 namespace config = utils::config;
35 
36 
37 /// Constructs a new error with a plain-text message.
38 ///
39 /// \param message The plain-text error message.
40 config::error::error(const std::string& message) :
41     std::runtime_error(message)
42 {
43 }
44 
45 
46 /// Destructor for the error.
47 config::error::~error(void) throw()
48 {
49 }
50 
51 
52 /// Constructs a new error with a plain-text message.
53 ///
54 /// \param key The key that caused the combination conflict.
55 /// \param format The plain-text error message.
56 config::bad_combination_error::bad_combination_error(
57     const detail::tree_key& key, const std::string& format) :
58     error(F(format.empty() ? "Combination conflict in key '%s'" : format) %
59           detail::flatten_key(key))
60 {
61 }
62 
63 
64 /// Destructor for the error.
65 config::bad_combination_error::~bad_combination_error(void) throw()
66 {
67 }
68 
69 
70 /// Constructs a new error with a plain-text message.
71 ///
72 /// \param message The plain-text error message.
73 config::invalid_key_error::invalid_key_error(const std::string& message) :
74     error(message)
75 {
76 }
77 
78 
79 /// Destructor for the error.
80 config::invalid_key_error::~invalid_key_error(void) throw()
81 {
82 }
83 
84 
85 /// Constructs a new error with a plain-text message.
86 ///
87 /// \param key The unknown key.
88 /// \param message The plain-text error message.
89 config::invalid_key_value::invalid_key_value(const detail::tree_key& key,
90                                              const std::string& message) :
91     error(F("Invalid value for property '%s': %s")
92           % detail::flatten_key(key) % message)
93 {
94 }
95 
96 
97 /// Destructor for the error.
98 config::invalid_key_value::~invalid_key_value(void) throw()
99 {
100 }
101 
102 
103 /// Constructs a new error with a plain-text message.
104 ///
105 /// \param message The plain-text error message.
106 config::syntax_error::syntax_error(const std::string& message) :
107     error(message)
108 {
109 }
110 
111 
112 /// Destructor for the error.
113 config::syntax_error::~syntax_error(void) throw()
114 {
115 }
116 
117 
118 /// Constructs a new error with a plain-text message.
119 ///
120 /// \param key The unknown key.
121 /// \param format The message for the error.  Must include a single "%s"
122 ///     placedholder, which will be replaced by the key itself.
123 config::unknown_key_error::unknown_key_error(const detail::tree_key& key,
124                                              const std::string& format) :
125     error(F(format.empty() ? "Unknown configuration property '%s'" : format) %
126           detail::flatten_key(key))
127 {
128 }
129 
130 
131 /// Destructor for the error.
132 config::unknown_key_error::~unknown_key_error(void) throw()
133 {
134 }
135 
136 
137 /// Constructs a new error with a plain-text message.
138 ///
139 /// \param message The plain-text error message.
140 config::value_error::value_error(const std::string& message) :
141     error(message)
142 {
143 }
144 
145 
146 /// Destructor for the error.
147 config::value_error::~value_error(void) throw()
148 {
149 }
150