xref: /llvm-project/lldb/packages/Python/lldbsuite/test_event/build_exception.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1b42d51baSPavel Labathfrom lldbsuite.support import seven
2eee887e0SPavel Labath
3b9c1b51eSKate Stone
4*2238dcc3SJonas Devlieghereclass BuildError(Exception):
54728cf7eSTodd Fiala    def __init__(self, called_process_error):
64728cf7eSTodd Fiala        super(BuildError, self).__init__("Error when building test subject")
7b42d51baSPavel Labath        self.command = seven.join_for_shell(called_process_error.cmd)
8eee887e0SPavel Labath        self.build_error = called_process_error.output
94728cf7eSTodd Fiala
104728cf7eSTodd Fiala    def __str__(self):
114728cf7eSTodd Fiala        return self.format_build_error(self.command, self.build_error)
124728cf7eSTodd Fiala
134728cf7eSTodd Fiala    @staticmethod
144728cf7eSTodd Fiala    def format_build_error(command, command_output):
154728cf7eSTodd Fiala        return "Error when building test subject.\n\nBuild Command:\n{}\n\nBuild Command Output:\n{}".format(
16*2238dcc3SJonas Devlieghere            command, command_output
17*2238dcc3SJonas Devlieghere        )
18