diff --git a/osbuild/api.py b/osbuild/api.py index b431af69..2c65a0ff 100644 --- a/osbuild/api.py +++ b/osbuild/api.py @@ -144,7 +144,7 @@ class API(BaseAPI): self._output_pipe = None self.monitor = monitor self.metadata = {} - self.exception = None + self.error = None @property def output(self): @@ -187,7 +187,10 @@ class API(BaseAPI): sock.send({"type": "fd", "fd": 0}, fds=fds) def _get_exception(self, message): - self.exception = message["exception"] + self.error = { + "type": "exception", + "data": message["exception"], + } def _message(self, msg, fds, sock): if msg["method"] == 'add-metadata': diff --git a/osbuild/pipeline.py b/osbuild/pipeline.py index e535a936..118fcf15 100644 --- a/osbuild/pipeline.py +++ b/osbuild/pipeline.py @@ -93,7 +93,7 @@ class Stage: binds=[os.fspath(tree) + ":/run/osbuild/tree"], readonly_binds=ro_binds) - return BuildResult(self, r.returncode, r.output, api.metadata, api.exception) + return BuildResult(self, r.returncode, r.output, api.metadata, api.error) class Assembler: @@ -152,7 +152,7 @@ class Assembler: binds=binds, readonly_binds=ro_binds) - return BuildResult(self, r.returncode, r.output, api.metadata, api.exception) + return BuildResult(self, r.returncode, r.output, api.metadata, api.error) class Pipeline: diff --git a/test/mod/test_api.py b/test/mod/test_api.py index be825ec5..ee42a80a 100644 --- a/test/mod/test_api.py +++ b/test/mod/test_api.py @@ -96,8 +96,13 @@ class TestAPI(unittest.TestCase): p = mp.Process(target=exception, args=(path, )) p.start() p.join() - self.assertIsNotNone(api.exception, "Exception not set") - self.assertEqual(api.exception["value"], "osbuild test exception") + self.assertIsNotNone(api.error, "Error not set") + self.assertIn("type", api.error, "Error has no 'type' set") + self.assertEqual("exception", api.error["type"], "Not an exception") + e = api.error["data"] + for field in ("type", "value", "traceback"): + self.assertIn(field, e, f"Exception needs '{field}'") + self.assertEqual(e["value"], "osbuild test exception") def test_metadata(self): # Check that `api.metadata` leads to `API.metadata` being