This PR is a minor improvement for error handling. It defines and exports the common errors in the protocol decode methods.
Usually, the same error would occur repeatedly, like fmt.Errorf("invalid netflow version (%d)", h.Version).
With predefined errors, it would be easier for the user of the library to aggregate the error stats.
The static errors (created by errors.New) are also predefined and reused, instead of creating new one on the fly.
This PR is a minor improvement for error handling. It defines and exports the common errors in the protocol decode methods.
fmt.Errorf("invalid netflow version (%d)", h.Version)
. With predefined errors, it would be easier for the user of the library to aggregate the error stats.errors.New
) are also predefined and reused, instead of creating new one on the fly.