Files
spark/src/lib/config/ConfigurationException.h
T
2017-08-07 17:21:12 -04:00

76 lines
1.8 KiB
C++
Executable File

#ifndef BADCONFIGURATIONEXCEPTION_H_
#define BADCONFIGURATIONEXCEPTION_H_
#include <string>
#include <stdexcept>
#include <sstream>
#include "lib/utils/bts_export.h"
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 in to 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;
}
};
}}
#endif