68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
#ifndef BADCONFIGURATIONEXCEPTION_H_
|
|
#define BADCONFIGURATIONEXCEPTION_H_
|
|
|
|
#include "lib/utils/bts_export.h"
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace bts {
|
|
namespace config {
|
|
|
|
class ConfigurationException : public std::logic_error {
|
|
public:
|
|
ConfigurationException(const char *what);
|
|
ConfigurationException(const std::string &what);
|
|
ConfigurationException(const ConfigurationException &other);
|
|
ConfigurationException &operator=(const ConfigurationException &other);
|
|
virtual ~ConfigurationException() throw();
|
|
|
|
BTS_EXPORT const char *what() const throw() override;
|
|
|
|
protected:
|
|
std::string _what;
|
|
};
|
|
|
|
class InvalidDescriptorException : public ConfigurationException {
|
|
public:
|
|
InvalidDescriptorException(const char *what) : ConfigurationException(what) {
|
|
_what += " was not compiled into config.";
|
|
}
|
|
};
|
|
|
|
class InvalidKeyException : public ConfigurationException {
|
|
public:
|
|
InvalidKeyException(const char *what) : ConfigurationException(what) {
|
|
_what += " is not a valid config type.";
|
|
}
|
|
};
|
|
|
|
class SelfReferenceException : public ConfigurationException {
|
|
public:
|
|
SelfReferenceException(const char *what, const char *file, int line, int col)
|
|
: ConfigurationException(what) {
|
|
std::ostringstream out;
|
|
out << what;
|
|
out << " Location: " << file << ":" << line << "," << col;
|
|
_what = out.str();
|
|
}
|
|
};
|
|
|
|
class RecursiveReferenceException : public ConfigurationException {
|
|
public:
|
|
RecursiveReferenceException(const char *what)
|
|
: ConfigurationException(what) {}
|
|
};
|
|
|
|
class ServerUnreachableException : public ConfigurationException {
|
|
public:
|
|
ServerUnreachableException(const char *what) : ConfigurationException(what) {
|
|
_what = "Unable to reach server ";
|
|
_what += what;
|
|
}
|
|
};
|
|
|
|
} // namespace config
|
|
} // namespace bts
|
|
#endif
|