diff --git a/osbuild/api.py b/osbuild/api.py index 2c65a0ff..baa985ae 100644 --- a/osbuild/api.py +++ b/osbuild/api.py @@ -213,7 +213,7 @@ def exception(e, path="/run/osbuild/api/osbuild"): msg = { "method": "exception", "exception": { - "type": str(type(e)), + "type": type(e).__name__, "value": str(e), "traceback": str(e.__traceback__) } diff --git a/test/mod/test_api.py b/test/mod/test_api.py index ee42a80a..c244b4b0 100644 --- a/test/mod/test_api.py +++ b/test/mod/test_api.py @@ -103,6 +103,7 @@ class TestAPI(unittest.TestCase): for field in ("type", "value", "traceback"): self.assertIn(field, e, f"Exception needs '{field}'") self.assertEqual(e["value"], "osbuild test exception") + self.assertEqual(e["type"], "ValueError") def test_metadata(self): # Check that `api.metadata` leads to `API.metadata` being