Skip to content

Commit 1b52f75

Browse files
committed
Add carna.base.AssertionFailure
1 parent e4dcad3 commit 1b52f75

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/py/base.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ static void configureLog( bool enabled )
293293
PYBIND11_MODULE( base, m )
294294
{
295295

296-
//py::register_exception< AssertionFailure >( m, "AssertionFailure" ); // error: 'const class Carna::base::AssertionFailure' has no member named 'what'
296+
py::register_exception< Carna::base::CarnaException >( m, "CarnaException" );
297+
py::register_exception< Carna::base::AssertionFailure >( m, "AssertionFailure" );
297298

298299
m.def( "logging",
299300
[]( bool enabled )

test/test_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ def test__attach_child__circular(self):
6868
node1 = carna.base.Node()
6969
node2 = carna.base.Node()
7070
node1.attach_child(node2)
71-
with self.assertRaises(RuntimeError):
71+
with self.assertRaises(carna.base.AssertionFailure):
7272
node2.attach_child(node1)
7373

7474
def test__attach_child__nonfree(self):
7575
node1 = carna.base.Node()
7676
node2 = carna.base.Node()
7777
node3 = carna.base.Node()
7878
node1.attach_child(node2)
79-
with self.assertRaises(RuntimeError):
79+
with self.assertRaises(carna.base.AssertionFailure):
8080
node3.attach_child(node2)
8181

8282

@@ -403,7 +403,7 @@ def test__plane__by_support(self):
403403
)
404404

405405
def test__plane__zero_normal(self):
406-
with self.assertRaises(RuntimeError):
406+
with self.assertRaises(carna.base.AssertionFailure):
407407
carna.base.math.plane(normal=[0, 0, 0], distance=0)
408408

409409

0 commit comments

Comments
 (0)