ti2 1.0.60 → 1.0.61

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.
@@ -106,7 +106,10 @@ describe('allotment', () => {
106
106
  expect(call.token).toEqual(token);
107
107
  });
108
108
  it('should be able to receive an axios error', async () => {
109
+ const mock = new MockAdapter(axios);
110
+ mock.onGet('http://www.example.com').reply(500, { what: 'nothing here' });
109
111
  let urlParamsError = new URLSearchParams({
112
+
110
113
  ...payload,
111
114
  keyPath: 'errorAxios',
112
115
  }).toString();
@@ -116,7 +119,7 @@ describe('allotment', () => {
116
119
  expectStatusCode: 500,
117
120
  });
118
121
  expect(returnValue.allotments).toBeFalsy();
119
- expect(returnValue.message).toBe('ECONNREFUSED');
122
+ expect(returnValue.message).toBe('nothing here');
120
123
  });
121
124
  it('should be able to receive an error from a regular response', async () => {
122
125
  const mock = new MockAdapter(axios);
package/index.js CHANGED
@@ -223,7 +223,9 @@ module.exports = async ({
223
223
  if (process.env.debug) console.error(`error in ${pluginName}`, errMsg);
224
224
  if (ti2Events.events) {
225
225
  ti2Events.events.emit(`${pluginName}.axios.error`, {
226
+ userId,
226
227
  response: axiosSafeResponse(response),
228
+ requestId: req.requestId,
227
229
  err: errMsg,
228
230
  });
229
231
  }
@@ -232,11 +234,14 @@ module.exports = async ({
232
234
  return response;
233
235
  }, err => {
234
236
  const errMsg = getErrorMessage({ err, handlers: errorPathsAxiosErrors });
235
- if (process.env.debug) console.error(`error in ${pluginName}`, args[0], errMsg);
237
+ if (process.env.debug) console.error(`error in ${pluginName}`, errMsg);
236
238
  if (ti2Events.events) {
237
239
  ti2Events.events.emit(`${pluginName}.axios.error`, {
238
- request: args[0],
240
+ userId,
241
+ requestId: req.requestId,
239
242
  err: errMsg,
243
+ ...(err.request ? { request: axiosSafeRequest(err.request) } : {}),
244
+ ...(err.response ? { response: axiosSafeRequest(err.response) } : {}),
240
245
  });
241
246
  }
242
247
  return Promise.reject(errMsg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "description": "Tourist Industry Exchange (TI2)",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test/plugin.js CHANGED
@@ -60,7 +60,7 @@ class Plugin {
60
60
  payload,
61
61
  } = args;
62
62
  if (payload.keyPath === 'errorAxios') {
63
- await axios.get('http://localhost:1235/');
63
+ await axios.get('http://www.example.com');
64
64
  }
65
65
  if (payload.keyPath === 'errorGeneral') {
66
66
  await axios.get('http://www.example.com');
@@ -75,7 +75,7 @@ class Plugin {
75
75
  },
76
76
  }));
77
77
  this.errorPathsAxiosErrors = jestPlugin.fn(() => ([
78
- ['code'],
78
+ ['response', 'data', 'what'],
79
79
  ]));
80
80
  this.errorPathsAxiosAny = jestPlugin.fn(() => ([
81
81
  err => {