Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 1c9e8d8

Browse files
committed
more explicit error message for dgpy.plug argument issues
thanks @jviereck
1 parent 834ff2f commit 1c9e8d8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/dynamic_graph/dynamic-graph-py.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ PyObject* plug(
4949
if (signalIn == NULL) {
5050
struct module_state* st = GETSTATE(m);
5151
std::ostringstream oss;
52-
oss << "dgpy.plug in argument must be a dynamic_graph.Signal, not a " << PyCapsule_GetName(objIn);
52+
oss << "dynamic_graph.plug(a, b): Argument 'b' must be of type 'dynamic_graph.Signal', but got "
53+
<< PyCapsule_GetName(objIn);
5354
PyErr_SetString(st->dgpyError, oss.str().c_str());
5455
return NULL;
5556
}
@@ -58,7 +59,8 @@ PyObject* plug(
5859
if (signalOut == NULL) {
5960
struct module_state* st = GETSTATE(m);
6061
std::ostringstream oss;
61-
oss << "dgpy.plug out argument must be a dynamic_graph.Signal, not a " << PyCapsule_GetName(objOut);
62+
oss << "dynamic_graph.plug(a, b): Argument 'a' must be of type 'dynamic_graph.Signal', but got "
63+
<< PyCapsule_GetName(objOut);
6264
PyErr_SetString(st->dgpyError, oss.str().c_str());
6365
return NULL;
6466
}

unitTesting/test_bindings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from custom_entity import CustomEntity
66

7+
ERR = "dynamic_graph.plug(a, b): Argument '%s' must be of type 'dynamic_graph.Signal', but got dynamic_graph.Entity"
8+
79

810
class BindingsTests(unittest.TestCase):
911
def test_bindings(self):
@@ -20,14 +22,12 @@ def test_type_check(self):
2022
# Check that we can't connect first.out to second
2123
with self.assertRaises(dg.dgpyError) as cm_in:
2224
dg.plug(first.signal('out_double'), second)
23-
self.assertEqual(str(cm_in.exception),
24-
"dgpy.plug in argument must be a dynamic_graph.Signal, not a dynamic_graph.Entity")
25+
self.assertEqual(str(cm_in.exception), ERR % 'b')
2526

2627
# Check that we can't connect first to second.in
2728
with self.assertRaises(dg.dgpyError) as cm_out:
2829
dg.plug(first, second.signal('in_double'))
29-
self.assertEqual(str(cm_out.exception),
30-
"dgpy.plug out argument must be a dynamic_graph.Signal, not a dynamic_graph.Entity")
30+
self.assertEqual(str(cm_out.exception), ERR % 'a')
3131

3232

3333
if __name__ == '__main__':

0 commit comments

Comments
 (0)