node_pcap
node_pcap copied to clipboard
Introduce more consistent way to handle errors while decoding
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)
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?
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.
https://github.com/mranney/node_pcap/blob/master/spec/ipv6headers/no_next.spec.js#L24
Is the first version of this idea.
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 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.