From 7d2c0585f879fc94c701b7929df51dca03e75f06 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Wed, 22 Jun 2016 14:57:31 +0000
Subject: [PATCH] ReplicateStorage: increase conflict error verbosity

---
 src/jio.storage/replicatestorage.js        | 8 ++++++--
 test/jio.storage/replicatestorage.tests.js | 6 ++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/jio.storage/replicatestorage.js b/src/jio.storage/replicatestorage.js
index dd981cf..258d11e 100644
--- a/src/jio.storage/replicatestorage.js
+++ b/src/jio.storage/replicatestorage.js
@@ -238,7 +238,9 @@
                                          id, options);
           }
           // Already exists on destination
-          throw new jIO.util.jIOError("Conflict on '" + id + "'",
+          throw new jIO.util.jIOError("Conflict on '" + id + "': " +
+                                      JSON.stringify(doc) + " !== " +
+                                      JSON.stringify(remote_doc),
                                       409);
         });
     }
@@ -343,7 +345,9 @@
                     return;
                   }
                   if (conflict_force !== true) {
-                    throw new jIO.util.jIOError("Conflict on '" + id + "'",
+                    throw new jIO.util.jIOError("Conflict on '" + id + "': " +
+                                                JSON.stringify(doc) + " !== " +
+                                                JSON.stringify(remote_doc),
                                                 409);
                   }
                 }
diff --git a/test/jio.storage/replicatestorage.tests.js b/test/jio.storage/replicatestorage.tests.js
index 7838a0c..570fb4e 100644
--- a/test/jio.storage/replicatestorage.tests.js
+++ b/test/jio.storage/replicatestorage.tests.js
@@ -859,7 +859,8 @@
       })
       .fail(function (error) {
         ok(error instanceof jIO.util.jIOError);
-        equal(error.message, "Conflict on 'conflict'");
+        equal(error.message, "Conflict on 'conflict': " +
+                             "{\"title\":\"foo\"} !== {\"title\":\"bar\"}");
         equal(error.status_code, 409);
       })
       .then(function () {
@@ -1383,7 +1384,8 @@
       })
       .fail(function (error) {
         ok(error instanceof jIO.util.jIOError);
-        equal(error.message, "Conflict on '" + id + "'");
+        equal(error.message, "Conflict on '" + id + "': " +
+                             "{\"title\":\"foo4\"} !== {\"title\":\"foo5\"}");
         equal(error.status_code, 409);
       })
       .then(function () {
-- 
2.30.9