import json
from repository.file_system_repository import FileSystemRepository
from usecases.exit_freecad_use_case import (
    ExitFreeCadUseCase,
)


class ErrorStringModel:
    def __init__(self, error: str) -> None:
        self.error = error
        pass

    error: str

    def toString(self) -> str:
        return json.dumps(
            {
                "error": self.error,
            },
            ensure_ascii=False,
            indent=4,
        )

    def toFileSystem(self, path: str):
        return (
            FileSystemRepository.writeFile(self.toString(), path, "error.json"),
            ExitFreeCadUseCase.call(),
        )
