diff mbox series

[ovs-dev,21/23] db-ctl-base: Don't die in cmd_remove() on error.

Message ID 20180702105019.10345-22-jkbs@redhat.com
State Accepted
Headers show
Series Don't use ctl_fatal() in command handlers from db-ctl-base | expand

Commit Message

Jakub Sitnicki July 2, 2018, 10:50 a.m. UTC
Return the error via the context instead of calling ctl_fatal() so that
the caller can decide how to handle it.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
---
 lib/db-ctl-base.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
index 7c1e10373..585cf67a0 100644
--- a/lib/db-ctl-base.c
+++ b/lib/db-ctl-base.c
@@ -1582,18 +1582,19 @@  cmd_remove(struct ctl_context *ctx)
                     return;
                 }
             } else {
-                ctl_fatal("%s", error);
+                ctx->error = error;
+                return;
             }
         }
         ovsdb_datum_subtract(&old, type, &rm, &rm_type);
         ovsdb_datum_destroy(&rm, &rm_type);
     }
     if (old.n < type->n_min) {
-        ctl_fatal("\"remove\" operation would put %u %s in column %s of "
-                  "table %s but the minimum number is %u",
-                  old.n,
+        ctl_error(ctx, "\"remove\" operation would put %u %s in column %s of "
+                  "table %s but the minimum number is %u", old.n,
                   type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs",
                   column->name, table->name, type->n_min);
+        return;
     }
     ovsdb_idl_txn_verify(row, column);
     ovsdb_idl_txn_write(row, column, &old);