Home | History | Annotate | Line # | Download | only in config
      1 // Copyright 2012 Google Inc.
      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 message The plain-text error message.
     55 config::invalid_key_error::invalid_key_error(const std::string& message) :
     56     error(message)
     57 {
     58 }
     59 
     60 
     61 /// Destructor for the error.
     62 config::invalid_key_error::~invalid_key_error(void) throw()
     63 {
     64 }
     65 
     66 
     67 /// Constructs a new error with a plain-text message.
     68 ///
     69 /// \param message The plain-text error message.
     70 config::syntax_error::syntax_error(const std::string& message) :
     71     error(message)
     72 {
     73 }
     74 
     75 
     76 /// Destructor for the error.
     77 config::syntax_error::~syntax_error(void) throw()
     78 {
     79 }
     80 
     81 
     82 /// Constructs a new error with a plain-text message.
     83 ///
     84 /// \param key The unknown key.
     85 /// \param format The message for the error.  Must include a single "%s"
     86 ///     placedholder, which will be replaced by the key itself.
     87 config::unknown_key_error::unknown_key_error(const detail::tree_key& key,
     88                                              const std::string& format) :
     89     error(F(format.empty() ? "Unknown configuration property '%s'" : format) %
     90           detail::flatten_key(key))
     91 {
     92 }
     93 
     94 
     95 /// Destructor for the error.
     96 config::unknown_key_error::~unknown_key_error(void) throw()
     97 {
     98 }
     99 
    100 
    101 /// Constructs a new error with a plain-text message.
    102 ///
    103 /// \param message The plain-text error message.
    104 config::value_error::value_error(const std::string& message) :
    105     error(message)
    106 {
    107 }
    108 
    109 
    110 /// Destructor for the error.
    111 config::value_error::~value_error(void) throw()
    112 {
    113 }
    114