#pragma once
#include <string>
#include <atomic>

namespace Create::Exceptions {
    enum Type {
        None,
        ComponentLoad,
        MissingField,
        InvalidFormat,
        SystemFailure,
        AssetMissing,
        FileIO,
        RuntimeLogic
    };

    const char* ExceptionToString(Type type);
}

class RecoverableError {
public:
    RecoverableError(const std::string& msg, Create::Exceptions::Type type = Create::Exceptions::None);
    void Handle() const;

private:
    std::string message;
    Create::Exceptions::Type type;
};

class FatalError {
public:
    FatalError(const std::string& msg, Create::Exceptions::Type type = Create::Exceptions::None);
};


class Engine;

class SignalHandler {
public:
    static void Init(Engine* enginePtr);

    static bool IsInterrupted();

private:
    static std::atomic<bool> interrupted;
    static Engine* engine;

    static void HandleSignal(int signal);
};
