From 4b93d30ec0a2d4e8c49a2118dfa46e2ae0a8d11a Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sat, 19 Jan 2019 21:07:21 -0800 Subject: [PATCH] Send correct error message for dataDir conflict --- src/apps.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apps.js b/src/apps.js index 6a1285049..027e54da3 100644 --- a/src/apps.js +++ b/src/apps.js @@ -327,21 +327,21 @@ function getDuplicateErrorDetails(location, portBindings, error) { assert.strictEqual(typeof portBindings, 'object'); assert.strictEqual(error.reason, DatabaseError.ALREADY_EXISTS); - var match = error.message.match(/ER_DUP_ENTRY: Duplicate entry '(.*)' for key/); + var match = error.message.match(/ER_DUP_ENTRY: Duplicate entry '(.*)' for key '(.*)'/); if (!match) { debug('Unexpected SQL error message.', error); - return new AppsError(AppsError.INTERNAL_ERROR); + return new AppsError(AppsError.INTERNAL_ERROR, error); } // check if the location conflicts - if (match[1] === location) return new AppsError(AppsError.ALREADY_EXISTS); + if (match[1] === location) return new AppsError(AppsError.ALREADY_EXISTS, `${match[2]} '${match[1]}' is in use`); // check if any of the port bindings conflict for (let portName in portBindings) { if (portBindings[portName] === parseInt(match[1])) return new AppsError(AppsError.PORT_CONFLICT, match[1]); } - return new AppsError(AppsError.ALREADY_EXISTS); + return new AppsError(AppsError.ALREADY_EXISTS, `${match[2]} '${match[1]}' is in use`); } // app configs that is useful for 'archival' into the app backup config.json