# How to catch error of Zip node

**URL:** <https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098>\
**Category:** General\
**Created:** [19 September 2020 23:21 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098 "2020-09-19T23:21:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [19 September 2020 23:21 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/1 "2020-09-19T23:21:29Z")

</div>

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 [https://stuk.github.io/jszip/documentation/howto/read\_zip.html](https://stuk.github.io/jszip/documentation/howto/read_zip.html)_" (★)

 ![node-zip-1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/c/cc5c54839022d19bb6436d44035724d64d4b183c.png)

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.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 September 2020 06:36 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/2 "2020-09-20T06:36:09Z")

</div>

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](https://nodered.org/docs/creating-nodes/node-js#handling-errors) uses `done` to report errors.

Either method works.

You could raise an issue on the [repository](https://github.com/gfcittolin/node-red-contrib-zip) & if the developer is still active & responsive, they might fix it.

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [20 September 2020 06:39 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/3 "2020-09-20T06:39:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [20 September 2020 07:29 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/4 "2020-09-20T07:29:01Z")

</div>

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.

 ![node-zip-3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/db334d11b1ed940a310e0d05239da748cf6b1c13.png)

and here is my flow:

```auto
[{"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/Data.zip","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:  
[http://www.mediafire.com/file/dztidjddqmtoio4/Data.zip/file](http://www.mediafire.com/file/dztidjddqmtoio4/Data.zip/file)

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

Any idea will be great.  
Thanks.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 September 2020 07:59 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/5 "2020-09-20T07:59:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 September 2020 08:27 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/6 "2020-09-20T08:27:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [20 September 2020 11:07 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/7 "2020-09-20T11:07:27Z")

</div>

Thank everyone very much!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 September 2020 19:27 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/8 "2020-09-21T19:27:39Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [22 September 2020 01:45 UTC](https://discourse.nodered.org/t/how-to-catch-error-of-zip-node/33098/9 "2020-09-22T01:45:48Z")

</div>

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