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.
- package/controllers/__tests__/allotments.js +4 -1
- package/index.js +7 -2
- package/package.json +1 -1
- package/test/plugin.js +2 -2
|
@@ -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('
|
|
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}`,
|
|
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
|
-
|
|
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
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://
|
|
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
|
-
['
|
|
78
|
+
['response', 'data', 'what'],
|
|
79
79
|
]));
|
|
80
80
|
this.errorPathsAxiosAny = jestPlugin.fn(() => ([
|
|
81
81
|
err => {
|