Path: blob/main/contrib/kyua/utils/config/exceptions.cpp
48081 views
// Copyright 2012 The Kyua Authors.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728#include "utils/config/exceptions.hpp"2930#include "utils/config/tree.ipp"31#include "utils/format/macros.hpp"3233namespace config = utils::config;343536/// Constructs a new error with a plain-text message.37///38/// \param message The plain-text error message.39config::error::error(const std::string& message) :40std::runtime_error(message)41{42}434445/// Destructor for the error.46config::error::~error(void) throw()47{48}495051/// Constructs a new error with a plain-text message.52///53/// \param key The key that caused the combination conflict.54/// \param format The plain-text error message.55config::bad_combination_error::bad_combination_error(56const detail::tree_key& key, const std::string& format) :57error(F(format.empty() ? "Combination conflict in key '%s'" : format) %58detail::flatten_key(key))59{60}616263/// Destructor for the error.64config::bad_combination_error::~bad_combination_error(void) throw()65{66}676869/// Constructs a new error with a plain-text message.70///71/// \param message The plain-text error message.72config::invalid_key_error::invalid_key_error(const std::string& message) :73error(message)74{75}767778/// Destructor for the error.79config::invalid_key_error::~invalid_key_error(void) throw()80{81}828384/// Constructs a new error with a plain-text message.85///86/// \param key The unknown key.87/// \param message The plain-text error message.88config::invalid_key_value::invalid_key_value(const detail::tree_key& key,89const std::string& message) :90error(F("Invalid value for property '%s': %s")91% detail::flatten_key(key) % message)92{93}949596/// Destructor for the error.97config::invalid_key_value::~invalid_key_value(void) throw()98{99}100101102/// Constructs a new error with a plain-text message.103///104/// \param message The plain-text error message.105config::syntax_error::syntax_error(const std::string& message) :106error(message)107{108}109110111/// Destructor for the error.112config::syntax_error::~syntax_error(void) throw()113{114}115116117/// Constructs a new error with a plain-text message.118///119/// \param key The unknown key.120/// \param format The message for the error. Must include a single "%s"121/// placedholder, which will be replaced by the key itself.122config::unknown_key_error::unknown_key_error(const detail::tree_key& key,123const std::string& format) :124error(F(format.empty() ? "Unknown configuration property '%s'" : format) %125detail::flatten_key(key))126{127}128129130/// Destructor for the error.131config::unknown_key_error::~unknown_key_error(void) throw()132{133}134135136/// Constructs a new error with a plain-text message.137///138/// \param message The plain-text error message.139config::value_error::value_error(const std::string& message) :140error(message)141{142}143144145/// Destructor for the error.146config::value_error::~value_error(void) throw()147{148}149150151