How to catch error of Zip node

I use a zip node to extract the zip file, in case the decompression fails, zip node will output an error "Error parsing zip file: Error: Can't find end of central directory : is this a zip file ? If it is, see" (★)

I want to catch this error with catch node, I used catch node and chose Catch errors from zip node but not catch error (★)

How to catch the error from zip node using catch node?
Any hint will be great.

Looking at the source code, node.error is called with only one argument. For errors to be catchable, there should be a 2nd argument.

In fact, the latest specification uses done to report errors.

Either method works.

You could raise an issue on the repository & if the developer is still active & responsive, they might fix it.

1 Like

@Steve-Mcl Thank you for the guidance!
I will think of ways to handle this error.

I tried to use function node to get the error message (★) but I couldn't catch it.
It seems that error message (★) only occurs at zip node and then stops.

and here is my flow:

[{"id":"9eea460e.25df18","type":"inject","z":"dc9ac215.0a6df","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"/Temp/","payloadType":"str","x":1680,"y":100,"wires":[["f052b6f7.8728f8"]]},{"id":"f5cb3e09.be381","type":"zip","z":"dc9ac215.0a6df","name":"unzip","mode":"decompress","filename":"","outasstring":false,"x":1950,"y":180,"wires":[["5a7a09e7.ce5e68"]]},{"id":"7e2270c9.b94ea","type":"file in","z":"dc9ac215.0a6df","name":"file in","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":1830,"y":180,"wires":[["f5cb3e09.be381"]]},{"id":"f052b6f7.8728f8","type":"change","z":"dc9ac215.0a6df","name":"change","rules":[{"t":"set","p":"filename","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1840,"y":100,"wires":[["7e2270c9.b94ea"]]},{"id":"c6ee6807.c57348","type":"debug","z":"dc9ac215.0a6df","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2210,"y":180,"wires":[]},{"id":"5a7a09e7.ce5e68","type":"function","z":"dc9ac215.0a6df","name":"","func":"msg.payload = msg;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2080,"y":240,"wires":[["c6ee6807.c57348"]]}]

zip file corrupted:

If you can suggest me the changes then I will try change and test my node-red!!!

Any idea will be great.

As @Steve-Mcl explained, it is currently impossible for your flow to catch that error.

As issue needs to be raised against the zip node so its author can fix how it logs the error.

1 Like

Unfortunately the node does not even send the error on its output, it just sends it to the debug pane and the log. An alternative would be to use an exec node to run unzip (or whatever is appropriate for your OS) to do it.

1 Like

Thank everyone very much!

@minhhn0205, in the spirit of open source, all this wonderful free software we use, please raise an issue on the repository. I'm certain if the author cares he will fix this issue.

@Steve-Mcl I raised an issue on the repository.