include/wrenbind17/exception.hpp

include/wrenbind17/exception.hpp #

Namespaces #

Name
wrenbind17

Classes #

Name
class wrenbind17::Exception
class wrenbind17::NotFound
class wrenbind17::BadCast
class wrenbind17::RuntimeError
class wrenbind17::CompileError

Source code #

#pragma once

#include <stdexcept>
#include <memory>
#include <string>

namespace wrenbind17 {
    class Exception : public std::exception {
    public:
        Exception() = default;

        explicit Exception(std::string msg) : msg(std::move(msg)) {
        }

        const char* what() const throw() override {
            return msg.c_str();
        }

    private:
        std::string msg;
    };

    class NotFound : public Exception {
    public:
        NotFound() : Exception("Not found") {
        }
    };

    class BadCast : public Exception {
    public:
        BadCast() : Exception("Bad cast") {
        }

        explicit BadCast(std::string msg) : Exception(std::move(msg)) {
        }
    };

    class RuntimeError : public Exception {
    public:
        explicit RuntimeError(std::string msg) : Exception(std::move(msg)) {
        }
    };

    class CompileError : public Exception {
    public:
        explicit CompileError(std::string msg) : Exception(std::move(msg)) {
        }
    };
} // namespace wrenbind17

Updated on 17 October 2023 at 12:26:25 UTC