From 0e2952968abad6e60cc5abb6ab8d2877565093e8 Mon Sep 17 00:00:00 2001 From: mcbouslog Date: Fri, 10 Mar 2017 16:16:22 -0600 Subject: [PATCH 1/3] return error object with status and response --- src/json-api-client.coffee | 5 +++-- src/make-http-request.coffee | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/json-api-client.coffee b/src/json-api-client.coffee index 6db0ecb..5734c7c 100644 --- a/src/json-api-client.coffee +++ b/src/json-api-client.coffee @@ -28,6 +28,7 @@ class JSONAPIClient extends Model mergeInto this, mixins beforeEveryRequest: -> + console.log 'using local json-api-client' Promise.resolve(); request: (method, url, payload, headers) -> @@ -101,9 +102,9 @@ class JSONAPIClient extends Model if attributeTypeName? type._links[attributeName].type = attributeTypeName - handleError: -> + handleError: (err) -> # Override this as necessary. - Promise.reject arguments... + Promise.reject err type: (name) -> @_typesCache[name] ?= new Type name, this diff --git a/src/make-http-request.coffee b/src/make-http-request.coffee index b1ccdb5..b281e00 100644 --- a/src/make-http-request.coffee +++ b/src/make-http-request.coffee @@ -43,9 +43,7 @@ makeHTTPRequest = (method, url, data, headers = {}, modify) -> if error?.status is 408 resolve makeHTTPRequest.apply null, originalArguments else if error? - # Prefer rejecting with the response, since it'll have more specific information. - # TODO: Reject with the error as expected and access the response through `error.response` in the handler. - reject response ? error + reject error else resolve response From ff7e2411e58f678fe59afcf44382bf28d0a1b8a4 Mon Sep 17 00:00:00 2001 From: mcbouslog Date: Mon, 13 Mar 2017 14:04:55 -0500 Subject: [PATCH 2/3] edit console log --- src/json-api-client.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/json-api-client.coffee b/src/json-api-client.coffee index 5734c7c..88eddf9 100644 --- a/src/json-api-client.coffee +++ b/src/json-api-client.coffee @@ -28,7 +28,7 @@ class JSONAPIClient extends Model mergeInto this, mixins beforeEveryRequest: -> - console.log 'using local json-api-client' + console.log 'using GitHub branch of json-api-client' Promise.resolve(); request: (method, url, payload, headers) -> From dec4bc2754687c136f8de352eec67e905062bcde Mon Sep 17 00:00:00 2001 From: mcbouslog Date: Tue, 14 Mar 2017 14:17:03 -0500 Subject: [PATCH 3/3] clean-up logs, revert unnecessary changes --- src/json-api-client.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/json-api-client.coffee b/src/json-api-client.coffee index 88eddf9..6db0ecb 100644 --- a/src/json-api-client.coffee +++ b/src/json-api-client.coffee @@ -28,7 +28,6 @@ class JSONAPIClient extends Model mergeInto this, mixins beforeEveryRequest: -> - console.log 'using GitHub branch of json-api-client' Promise.resolve(); request: (method, url, payload, headers) -> @@ -102,9 +101,9 @@ class JSONAPIClient extends Model if attributeTypeName? type._links[attributeName].type = attributeTypeName - handleError: (err) -> + handleError: -> # Override this as necessary. - Promise.reject err + Promise.reject arguments... type: (name) -> @_typesCache[name] ?= new Type name, this