package blue_engine::error;

import std::io;

public enum BlueEngineErrorCode {
    UpdateLoopError;
    AdapterNotFound;
    DeviceNotFound;
    LoadingTextureError;
    Custom;
}

public struct BlueEngineError {
    public:
        code: BlueEngineErrorCode;
        message: &const string;
        BlueEngineError(code: BlueEngineErrorCode, message: &const string) {
            this.code = code;
            this.message = message;
        }
        ~BlueEngineError() {
            delete this.message;
        }
        fun code(this) -> BlueEngineErrorCode {
            return this.code;
        }
        fun message(this) -> &const string {
            return this.message;
        }
        fun display() {
            if this.code == BlueEngineErrorCode::Custom {
                println("BlueEngineError: " + this.message);
            } if else this.code == BlueEngineErrorCode::UpdateLoopError {
                println("BlueEngineError: Update loop error occurred. " + this.message);
            } if else this.code == BlueEngineErrorCode::AdapterNotFound {
                println("BlueEngineError: No suitable adapter found. " + this.message);
            } if else this.code == BlueEngineErrorCode::DeviceNotFound {
                println("BlueEngineError: No suitable device found. " + this.message);
            } if else this.code == BlueEngineErrorCode::LoadingTextureError {
                println("BlueEngineError: Error while loading texture. " + this.message);
            }
        }
}