playov2-js-utilities 0.3.56 → 0.3.57

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.
@@ -21,7 +21,7 @@ const Logger = require('../logger.js');
21
21
  * @returns
22
22
  */
23
23
  const playoResponseHandler = (resp, requestId) => {
24
- if (resp.isAxiosError || resp.status >= 400) {
24
+ if (resp.isAxiosError) {
25
25
  //if axios error is triggered then axios throws HTTP code for timeout or other forms of unsuccessful errors
26
26
  const {
27
27
  code = "UNCAUGHT_ERROR",
@@ -38,7 +38,6 @@ const playoResponseHandler = (resp, requestId) => {
38
38
 
39
39
  const { status, data, config = { url: '' } } = resp;
40
40
  const { url = '' } = config;
41
-
42
41
  if (status >= 200 && status < 400) {
43
42
  const { requestStatus, message = 'success' } = data;
44
43
  if (!requestStatus && requestStatus != 0) { //if the service does not provide request status
@@ -48,6 +47,11 @@ const playoResponseHandler = (resp, requestId) => {
48
47
  return data
49
48
  }
50
49
 
50
+ if(status >= 400) {
51
+ Logger.prepareErrorLog(requestId, { code, message }, `Api call to url to ${url} failed`)
52
+ throw (data);
53
+ }
54
+
51
55
  else { // ideally this should not get triggered unless there is fault in calling lib itself
52
56
  Logger.prepareErrorLog(requestId, { response: resp }, "axios error");
53
57
  throw ({ requestStatus: 0, message: "Failed to handle response" })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playov2-js-utilities",
3
- "version": "0.3.56",
3
+ "version": "0.3.57",
4
4
  "description": "Private package for JS utility functions",
5
5
  "main": "index.js",
6
6
  "scripts": {