Better error message on failure to add dbgroup mapping.
authorGreg Sabino Mullane <greg@endpoint.com>
Fri, 10 Jun 2011 19:21:20 +0000 (15:21 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Fri, 10 Jun 2011 19:21:20 +0000 (15:21 -0400)
bucardo

diff --git a/bucardo b/bucardo
index 85e7dc0fee8983a04e7bebfd54b9e28f47e71921..1038095be378452636ef057ada36c434007399f3 100755 (executable)
--- a/bucardo
+++ b/bucardo
@@ -8293,7 +8293,16 @@ sub add_db_to_group {
 
     $SQL = 'INSERT INTO bucardo.dbmap(db,dbgroup,role) VALUES (?,?,?)';
     $sth = $dbh->prepare($SQL);
-    $sth->execute($db,$group,$role);
+    eval {
+        $sth->execute($db,$group,$role);
+    };
+    if ($@) {
+        my $msg = qq{Cannot add database "$db" to group "$group"};
+        if ($@ =~ /"db_dsn_unique"/) {
+            die qq{$msg: already have that entry\n};
+        }
+        die qq{$msg: $@\n};
+    }
 
     ## Reload our hashes
     load_bucardo_info(1);