From f58b7a264caa0dea597967fa46f6c6a79613eecd Mon Sep 17 00:00:00 2001 From: Blair Zajac Date: Thu, 5 Apr 2018 12:26:16 -0700 Subject: [PATCH] When a request fails, always set the data property. (#295) This is for consistency between the different ways an Error instance is created and populated. --- lib/clients/public.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/clients/public.js b/lib/clients/public.js index 8e508d61..448ddd00 100644 --- a/lib/clients/public.js +++ b/lib/clients/public.js @@ -63,6 +63,7 @@ class PublicClient { if (err) { err.response = response; + err.data = data; } else if (response.statusCode > 299) { err = new Error( `HTTP ${response.statusCode} Error: ${data && data.message}` @@ -72,6 +73,7 @@ class PublicClient { } else if (data === null) { err = new Error('Response could not be parsed as JSON'); err.response = response; + err.data = data; } if (typeof callback === 'function') {