]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
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 e21e95b33786c4aac7a1ffa44f8535d355c347a6..e0c37b6b88c6f286d88dfdf26fa963fa6161b05f 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);
 
        // 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;
                return NULL;
+       }
 
        PyObject* obj = new_network(&NetworkType, network);
        loc_network_unref(network);
 
        PyObject* obj = new_network(&NetworkType, network);
        loc_network_unref(network);