From 818c270e114d68d31b9fdc75feb1bfd10f0c4eef Mon Sep 17 00:00:00 2001 From: Herman Klushin Date: Tue, 7 Mar 2017 14:37:30 +0300 Subject: [PATCH] Update WLError.js Most time new errors created in code by call `new WLError(error)` --- lib/waterline/error/WLError.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/waterline/error/WLError.js b/lib/waterline/error/WLError.js index fb9993d7a..e2b5aaac0 100644 --- a/lib/waterline/error/WLError.js +++ b/lib/waterline/error/WLError.js @@ -16,7 +16,10 @@ function WLError(properties) { // Fold defined properties into the new WLError instance. properties || (properties = { }); _.extend(this, properties); - + + if (_.isObject(properties) && properties instanceof Error) { + this.originalError = properties; + } // Generate stack trace // (or use `originalError` if it is a true error instance) if (_.isObject(this.originalError) && this.originalError instanceof Error) {