Program Listing for File custom_exceptions.h

Return to documentation for file (necsim/custom_exceptions.h)

//This file is part of necsim project which is released under MIT license.
//See file **LICENSE.txt** or visit https://opensource.org/licenses/MIT) for full license details.
// Author: Samuel Thompson
// Contact: samuel.thompson14@imperial.ac.uk or thompsonsed@gmail.com
#ifndef CUSTOM_EXCEPTION_H
#define CUSTOM_EXCEPTION_H

#include <stdexcept>
#include <utility>
#include "Logging.h"

using namespace std;
namespace necsim
{
    struct FatalException : public runtime_error
    {
        FatalException() : runtime_error("Fatal exception thrown at run time, quitting program. ")
        { }

        explicit FatalException(string msg) : runtime_error(msg)
        {
#ifdef DEBUG
            writeLog(50, msg);
#endif //DEBUG
        }
    };

    struct ConfigException : public FatalException
    {
        ConfigException() : FatalException("Exception thrown at run time in config: ")
        { };

        explicit ConfigException(string msg) : FatalException(std::move(msg))
        { }
    };
}
#endif // CUSTOM_EXCEPTION_H