node_pcap icon indicating copy to clipboard operation
node_pcap copied to clipboard

Introduce more consistent way to handle errors while decoding

Open jmaxxz opened this issue 9 years ago • 5 comments

Do we want to raise an error event? Set an `_error' property? Continue throwing exception?

We definitely should not be writing out to the console (which is done in places at 2.0.1)

jmaxxz avatar Feb 27 '15 02:02 jmaxxz

The more I think about it, the more I like having an _error property. You don't have a lot of choices when encountering an error. Most people just want to skip them anyway.

So what's _error then, an array of strings? A single string that we concat?

mranney avatar Feb 27 '15 20:02 mranney

I don't know. I was thinking it would be string, as I don't know how a decoder would have more than one error. Though I have not thought about it enough, if multiple errors are possible then an array of strings makes the most sense.

jmaxxz avatar Feb 28 '15 00:02 jmaxxz

https://github.com/mranney/node_pcap/blob/master/spec/ipv6headers/no_next.spec.js#L24

Is the first version of this idea.

jmaxxz avatar Mar 11 '15 04:03 jmaxxz

Why not emit an error event, like any other Node module?

Add a flag to it to indicate if it's fatal, and if not, don't do anything else. If fatal, kill the session?

Domiii avatar May 15 '15 12:05 Domiii

@Domiii I can not say for sure that this will work at this time. But it sounds like something which we should at least look at.

jmaxxz avatar May 16 '15 21:05 jmaxxz