adrianmo / go-nmea

A NMEA parser library in pure Go
MIT License
226 stars 77 forks source link

a lot of new sentences #88

Closed aldas closed 2 years ago

aldas commented 2 years ago
aldas commented 2 years ago

About errors. When parsing fails currently only first error is stored and all subsequent errors are discarded. I propose if p.EnumString and other parsing method errors would be distinquishable from each other and parsers would store all errors. it would allow you to introspect what went wrong and some circumstances ignore some error types.

maybe just wrapping them (or storing into slice or multierror)

func (p *Parser) SetErr(context, value string) {
    if p.err == nil {
        p.err = fmt.Errorf("nmea: %s invalid %s: %s", p.Prefix(), context, value)
    } else {
        p.err = fmt.Errorf("nmea: %s invalid %s: %s, err: %w", p.Prefix(), context, value, p.err)
    }
}
icholy commented 2 years ago

This is awesome! Create a separate issue for the error discussion though.

aldas commented 2 years ago

added #89