Program Listing for File exception.hpp

Return to documentation for file (xnetwork/exception.hpp)

// -*- coding: utf-8 -*-
#pragma once

#include <exception>
// #include <initializer_list>
#include <stdexcept>

namespace xn
{

// static const auto __all__ = {
//     "HasACycle",
//     "NodeNotFound",
//     "PowerIterationFailedConvergence",
//     "ExceededMaxIterations",
//     "AmbiguousSolution",
//     "XNetworkAlgorithmError",
//     "XNetworkException",
//     "XNetworkError",
//     "XNetworkNoCycle",
//     "XNetworkNoPath",
//     "XNetworkNotImplemented",
//     "XNetworkPointlessConcept",
//     "XNetworkUnbounded",
//     "XNetworkUnfeasible",
// };

struct XNetworkException : std::runtime_error
{
    explicit XNetworkException(std::string_view msg)
        : std::runtime_error(msg)
    {
    }
};

struct XNetworkError : XNetworkException
{
    explicit XNetworkError(std::string_view msg)
        : XNetworkException(msg)
    {
    }
};

struct XNetworkPointlessConcept : XNetworkException
{
    explicit XNetworkPointlessConcept(std::string_view msg)
        : XNetworkException(msg)
    {
    }
};

struct XNetworkAlgorithmError : XNetworkException
{
    explicit XNetworkAlgorithmError(std::string_view msg)
        : XNetworkException(msg)
    {
    }
};

struct XNetworkUnfeasible : XNetworkAlgorithmError
{
    explicit XNetworkUnfeasible(std::string_view msg)
        : XNetworkAlgorithmError(msg)
    {
    }
};

struct XNetworkNoPath : XNetworkUnfeasible
{
    explicit XNetworkNoPath(std::string_view msg)
        : XNetworkUnfeasible(msg)
    {
    }
};

struct XNetworkNoCycle : XNetworkUnfeasible
{
    explicit XNetworkNoCycle(std::string_view msg)
        : XNetworkUnfeasible(msg)
    {
    }
};

struct HasACycle : XNetworkException
{
    explicit HasACycle(std::string_view msg)
        : XNetworkException(msg)
    {
    }
};

struct XNetworkUnbounded : XNetworkAlgorithmError
{
    explicit XNetworkUnbounded(std::string_view msg)
        : XNetworkAlgorithmError(msg)
    {
    }
};

struct XNetworkNotImplemented : XNetworkException
{
    explicit XNetworkNotImplemented(std::string_view msg)
        : XNetworkException(msg)
    {
    }
};

struct NodeNotFound : XNetworkException
{
    explicit NodeNotFound(std::string_view msg)
        : XNetworkException(msg)
    {
    }
};

struct AmbiguousSolution : XNetworkException
{
    explicit AmbiguousSolution(std::string_view msg)
        : XNetworkException(msg)
    {
    }
};

struct ExceededMaxIterations : XNetworkException
{
    explicit ExceededMaxIterations(std::string_view msg)
        : XNetworkException(msg)
    {
    }
};

//     /*! Raised when the power iteration method fails to converge within a
//     specified iteration limit.
//
//     `num_iterations` is the number of iterations that have been
//     completed when this exception was raised.
//
//      */
// class PowerIterationFailedConvergence : ExceededMaxIterations {
//     explicit _Self( num_iterations, *args, **kw) {
//         const auto msg = "power iteration failed to converge within {}
//         iterations"; exception_message = msg.format(num_iterations);
//         superinit = super(PowerIterationFailedConvergence, *this).__init__
//         superinit( exception_message, *args, **kw);
//     }
// };
} // namespace xn