from __future__ import annotations

from ..formatting import h16


class EmulatorError(Exception):
    pass


class UnsupportedInstruction(EmulatorError):
    def __init__(self, pc: int, raw: bytes, text: str) -> None:
        raw_text = " ".join(f"{byte:02X}" for byte in raw)
        super().__init__(f"unsupported instruction at {h16(pc)}: {raw_text} {text}".rstrip())
        self.pc = pc
        self.raw = raw
        self.text = text
