chargebee 2.8.0 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### v2.8.1 (2022-01-05)
2
+ * * *
3
+
4
+ ### Fixes:
5
+ * Improved error message for Invalid JSON response.
6
+
1
7
  ### v2.8.0 (2021-12-08)
2
8
  * * *
3
9
 
package/lib/chargebee.js CHANGED
@@ -8,7 +8,7 @@ ChargeBee._env = {
8
8
  hostSuffix: '.chargebee.com',
9
9
  apiPath: '/api/v2',
10
10
  timeout: 80000,
11
- clientVersion: 'v2.8.0',
11
+ clientVersion: 'v2.8.1',
12
12
  port: 443,
13
13
  timemachineWaitInMillis: 3000,
14
14
  exportWaitInMillis: 3000
@@ -191,7 +191,36 @@ ChargeBee._core = (function() {
191
191
  try {
192
192
  response = JSON.parse(response);
193
193
  } catch (e) {
194
- throwError(callBack,'client_error', 500, 'invalid_json', 'invalid json in response. Probably not a ChargeBee response', e);
194
+ if (response.includes('503')) {
195
+ return throwError(
196
+ callBack,
197
+ 'internal_temporary_error',
198
+ 503,
199
+ 'internal_temporary_error',
200
+ 'Sorry, the server is currently unable to handle the request due to a temporary overload or scheduled maintenance. Please retry after sometime.',
201
+ e
202
+ );
203
+ }
204
+ else if(response.includes('504')) {
205
+ return throwError(
206
+ callBack,
207
+ 'gateway_timeout',
208
+ 504,
209
+ 'gateway_timeout',
210
+ 'The server did not receive a timely response from an upstream server, request aborted. If this problem persists, contact us at support@chargebee.com.',
211
+ e
212
+ );
213
+ }
214
+ else {
215
+ return throwError(
216
+ callBack,
217
+ 'internal_error',
218
+ 500,
219
+ 'internal_error',
220
+ 'Sorry, something went wrong when trying to process the request. If this problem persists, contact us at support@chargebee.com.',
221
+ e
222
+ );
223
+ }
195
224
  }
196
225
  if (res.statusCode < 200 || res.statusCode > 299) {
197
226
  response.http_status_code = res.statusCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name":"chargebee",
3
- "version":"2.8.0",
3
+ "version":"2.8.1",
4
4
  "description":"A library for integrating with ChargeBee.",
5
5
  "keywords":[
6
6
  "payments",