Skip to content

Commit

Permalink
go: return a bad magic error in check when parsing summary (foxglove#…
Browse files Browse the repository at this point in the history
…1206)

### Changelog
- Changed: when attempting to read a corrupt MCAP using using the index,
the reader will return an ErrBadMagic instance rather than a bare Error.

### Docs

None.

### Description

it's useful to be able to tell this error apart from errors that might
result from i/o, but right now there is no simple way to determine this
using `errors.Is`. This PR gives the error a publicly known type, so
that callers can check for it.

<!-- In addition to unit tests, describe any manual testing you did to
validate this change. -->

<table><tr><th>Before</th><th>After</th></tr><tr><td>

<!--before content goes here-->

</td><td>

<!--after content goes here-->

</td></tr></table>

<!-- If necessary, link relevant Linear or Github issues. Use `Fixes:
foxglove/repo#1234` to auto-close the Github issue or Fixes: FG-### for
Linear isses. -->
  • Loading branch information
james-rms authored Jul 31, 2024
1 parent 4a9145d commit 71c5aa3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go/mcap/indexed_message_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (it *indexedMessageIterator) parseSummarySection() error {
}
magic := buf[20:]
if !bytes.Equal(magic, Magic) {
return fmt.Errorf("not an MCAP file")
return &ErrBadMagic{location: magicLocationEnd, actual: magic}
}
footer, err := ParseFooter(buf[:20])
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go/mcap/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mcap

// Version of the MCAP library.
var Version = "v1.4.1"
var Version = "v1.5.0"

0 comments on commit 71c5aa3

Please sign in to comment.