###############################################################################
# This file is part of the tango-takeoff project.
#
# Copyright Lund University
#
# Distributed under the GNU GPLv3 license. See LICENSE file for more info.
###############################################################################
from typing import Union


class TakeOffError(RuntimeError):
    def __init__(self, messages: Union[str, list[str]]):
        if type(messages) is str:
            messages = [messages]
        self.messages = messages
        super().__init__(self.__str__())

    def toJSON(self):
        return {"errors": self.messages}

    def __str__(self):
        return ", ".join(self.messages)


class TakeOffCommandFailed(TakeOffError):
    """Raised when some servers could not be started or stopped"""

    pass
