From 8ee8dac25cf9957f995d49c75084e0f0c4df0231 Mon Sep 17 00:00:00 2001 From: Samuel Marks Date: Wed, 12 Jul 2017 01:16:41 +1000 Subject: [PATCH 1/2] =?UTF-8?q?Quick-fix=20`Invalid=20attributes=20sent=20?= =?UTF-8?q?to=20undefined:\n=20=E2=80=A2=200\n`=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/waterline/error/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/waterline/error/index.js b/lib/waterline/error/index.js index 31c74f4e1..5f95b1b73 100644 --- a/lib/waterline/error/index.js +++ b/lib/waterline/error/index.js @@ -56,7 +56,12 @@ function duckType(err) { // Dress `unique` rule violations to be consistent with other // validation errors. - return new WLValidationError(err); + const er = new WLValidationError(err); + if (er.details === 'Invalid attributes sent to undefined:\n • 0\n' && er.rawMessage) { + er.code = err.code; + er.details = er.rawMessage; + } + return er; } // Unexpected miscellaneous error (`E_UNKNOWN`) From ee8db4ea0d766411a1297d76515e7f097e84a0be Mon Sep 17 00:00:00 2001 From: Samuel Marks Date: Wed, 12 Jul 2017 13:58:32 +1000 Subject: [PATCH 2/2] More hacks --- lib/waterline/error/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/waterline/error/index.js b/lib/waterline/error/index.js index 5f95b1b73..c6230064f 100644 --- a/lib/waterline/error/index.js +++ b/lib/waterline/error/index.js @@ -59,7 +59,11 @@ function duckType(err) { const er = new WLValidationError(err); if (er.details === 'Invalid attributes sent to undefined:\n • 0\n' && er.rawMessage) { er.code = err.code; - er.details = er.rawMessage; + er.details = er.reason = er.rawMessage = err.reason; + er.text = JSON.stringify({ + code: er.code, + message: '[Error (' + er.code + ')]: ' + er.details + }); } return er; }