Skip to content

Commit a39e1b9

Browse files
committed
impl(parser): add additional output for errors
1 parent 63ea4f3 commit a39e1b9

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"dependencies": {
3030
"@netresearch/node-magento-eqp": "^3.0.2",
31+
"axios": "^1.4.0",
3132
"node-red-contrib-typescript-node": "^0.1.0"
3233
},
3334
"devDependencies": {

src/magento-eqp-callback-parser.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
config: { value: '', type: 'magento-eqp-config', required: true }
1010
},
1111
inputs: 1,
12-
outputs: 1,
12+
outputs: 2,
1313
icon: 'file.png',
1414
label: function () {
1515
return this.name || 'Magento EQP Callback Parser';

src/magento-eqp-callback-parser.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EQPStatusUpdateEvent, MalwareScanCompleteEvent } from '@netresearch/node-magento-eqp';
2+
import { AxiosError } from 'axios';
23
import { NodeProperties, Red } from 'node-red';
34
import { Node } from 'node-red-contrib-typescript-node';
45
import { Message } from './common';
@@ -46,7 +47,7 @@ class MagentoEQPCallbackParser extends Node {
4647
// @ts-ignore
4748
msg.payload = await this.configNode.eqp.callbackService.parseCallback(payload);
4849

49-
this.send(msg);
50+
this.send([msg, null]);
5051
} catch (err) {
5152
const error = err as Error;
5253

@@ -55,6 +56,10 @@ class MagentoEQPCallbackParser extends Node {
5556
shape: 'ring',
5657
text: error.toString()
5758
});
59+
60+
const httpResponse = err instanceof AxiosError && !!err.response ? err.response.data : null;
61+
62+
this.send([null, { ...error, httpResponse }]);
5863
}
5964
});
6065
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ asynckit@^0.4.0:
274274
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
275275
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
276276

277-
277+
[email protected], axios@^1.4.0:
278278
version "1.4.0"
279279
resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f"
280280
integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==

0 commit comments

Comments
 (0)