1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/** @file
* This is the header file for some of the exception classes and for the base
* exception class BaseException.
* @author André Offringa <offringa@gmail.com>
*/
#ifndef BASEEXCEPTION_H
#define BASEEXCEPTION_H
#include <stdexcept>
#include <string>
/**
* The base exception class that all exceptions should inherit from.
*/
class BaseException : public std::runtime_error {
public:
/**
* Constructor that initialises the exception as if an unspecified error
* occured.
*/
BaseException() noexcept : std::runtime_error("Unspecified error") {}
/**
* Constructor that initialises the exception with a specified description.
* @param description The description that should describe the cause of the
* exception.
*/
explicit BaseException(const std::string& description) noexcept
: std::runtime_error(description) {}
/**
* Destructor.
*/
virtual ~BaseException() noexcept {}
private:
};
/**
* Exception that is throwed in case of Input/Output exceptions.
*/
class IOException : public BaseException {
public:
/**
* Constructor that initialises the IOException without a description.
*/
IOException() noexcept : BaseException() {}
/**
* Constructor that initialises the IOException with a description
* @param description The description of the Input/Output exception
*/
explicit IOException(const std::string& description) noexcept
: BaseException(description) {}
};
/**
* Exception that is throwed in case of an incorrect configuration
*/
class ConfigurationException : public BaseException {
public:
/**
* Constructor that initialises the ConfigurationException with a description
* @param description The description of the configuration error
*/
explicit ConfigurationException(const std::string& description) noexcept
: BaseException(description) {}
};
/**
* Exception that is throwed in case of an incorrect usage of a function
*/
class BadUsageException : public BaseException {
public:
/**
* Constructor that initialises the BadUsageException with a description
* @param description The description of the incorrect usage
*/
explicit BadUsageException(const std::string& description) noexcept
: BaseException(description) {}
};
#endif
|