37 lines
754 B
C++
37 lines
754 B
C++
#ifndef TYCHE_VM_EXCEPTIONS_HH
|
|
#define TYCHE_VM_EXCEPTIONS_HH
|
|
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace tyche {
|
|
|
|
class VMRuntimeError : public std::runtime_error
|
|
{
|
|
public:
|
|
explicit VMRuntimeError(std::string const& str) : std::runtime_error(str.c_str()) {}
|
|
};
|
|
|
|
class VMStackUnderflow : public VMRuntimeError
|
|
{
|
|
public:
|
|
explicit VMStackUnderflow() : VMRuntimeError("Stack underflow") {}
|
|
};
|
|
|
|
class VMStackOutOfRange : public VMRuntimeError
|
|
{
|
|
public:
|
|
explicit VMStackOutOfRange() : VMRuntimeError("Item does not exist in stack") {}
|
|
};
|
|
|
|
class VMTypeError : public VMRuntimeError
|
|
{
|
|
public:
|
|
explicit VMTypeError(Type expected, Type found) : VMRuntimeError("Type error") {} // TODO - print types
|
|
};
|
|
|
|
|
|
}
|
|
|
|
#endif //TYCHE_VM_EXCEPTIONS_HH
|