From 9eb022170f8212aefe0b7d2418188ce9ee7241f3 Mon Sep 17 00:00:00 2001 From: jasonkneen Date: Fri, 21 Apr 2017 16:10:05 +0100 Subject: [PATCH] Change error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Local error handlers take priority — if none, then global. If no global unload or error. If the calling app wants to pass local error handling to global they can do that outside of rest. --- reste.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/reste.js b/reste.js index a3b2bfd..b90b555 100644 --- a/reste.js +++ b/reste.js @@ -169,16 +169,10 @@ var main = function() { warn("RESTE:: Future versions of RESTe will return errors as objects. Use config.errorsAsObjects = true to support this now and update your apps!"); } - // if we have an onError method, use it - if (config.onError) { - // if we have a global onError, we'll pass it on too do we can still use it locally if we want to - if (onError) { - onError(error, retry, config.onError); - } else { - config.onError(error, retry); - } - } else if (onError) { + if (onError) { onError(error, retry); + } else if (config.onError) { + config.onError(error, retry); } else if (onLoad) { // otherwise revert to the onLoad callback onLoad(error, retry);