writer: Throw better exception when network address was invalid
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 15:24:45 +0000 (15:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 15:24:45 +0000 (15:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/writer.c

index e21e95b..e0c37b6 100644 (file)
@@ -127,8 +127,12 @@ static PyObject* Writer_add_network(WriterObject* self, PyObject* args) {
 
        // Create network object
        int r = loc_writer_add_network(self->writer, &network, string);
-       if (r)
+       if (r) {
+               if (r == -EINVAL)
+                       PyErr_SetString(PyExc_ValueError, "Invalid network");
+
                return NULL;
+       }
 
        PyObject* obj = new_network(&NetworkType, network);
        loc_network_unref(network);