From a10a849950ef989d1e8b09326b4a3d6ccc36bd22 Mon Sep 17 00:00:00 2001 From: Dave Wasmer Date: Thu, 10 Dec 2015 16:09:06 -0700 Subject: [PATCH] Remove extraneous conditional in ajax() The conditional was checking if `error` was not an instance of `Error`, but it was initialized on the previous line, ensuring the conditional would always pass. --- addon/adapters/rest-adapter.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/addon/adapters/rest-adapter.js b/addon/adapters/rest-adapter.js index ed3b9df8ec7..3b0426f20c6 100644 --- a/addon/adapters/rest-adapter.js +++ b/addon/adapters/rest-adapter.js @@ -842,21 +842,19 @@ export default Adapter.extend(BuildURLMixin, { hash.error = function(jqXHR, textStatus, errorThrown) { let error; - if (!(error instanceof Error)) { - if (errorThrown instanceof Error) { - error = errorThrown; - } else if (textStatus === 'timeout') { - error = new TimeoutError(); - } else if (textStatus === 'abort') { - error = new AbortError(); - } else { - error = adapter.handleResponse( - jqXHR.status, - parseResponseHeaders(jqXHR.getAllResponseHeaders()), - adapter.parseErrorResponse(jqXHR.responseText) || errorThrown, - requestData - ); - } + if (errorThrown instanceof Error) { + error = errorThrown; + } else if (textStatus === 'timeout') { + error = new TimeoutError(); + } else if (textStatus === 'abort') { + error = new AbortError(); + } else { + error = adapter.handleResponse( + jqXHR.status, + parseResponseHeaders(jqXHR.getAllResponseHeaders()), + adapter.parseErrorResponse(jqXHR.responseText) || errorThrown, + requestData + ); } Ember.run.join(null, reject, error);