From 6fad3d5d95c4a80da5e4b96bbfcf99d9a9807e50 Mon Sep 17 00:00:00 2001 From: Cody Stoltman Date: Fri, 5 Feb 2016 08:15:44 -0600 Subject: [PATCH] add error normalization - as part of https://github.com/balderdashy/waterline-adapter-tests/pull/89 --- lib/connections/spawn.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/connections/spawn.js b/lib/connections/spawn.js index 2632e434..30fed004 100644 --- a/lib/connections/spawn.js +++ b/lib/connections/spawn.js @@ -88,6 +88,12 @@ module.exports = function spawnConnection (connectionObject, fn, cb__spawnConnec // Release the connection, then pass control back to Waterline core. connectionObject.connection.releaseConnection(liveConnection, function sendBackError ( /* thisErrDoesntMatter */ ) { + + // Normalize the errors a bit. There could be a formattedErr if we inspect + // and augment the error. But to ensure compatibility with other adapters attach an + // originalError key to th error. + err.originalError = err; + cb__spawnConnection(err); }); return;