-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8286263
commit 0f35709
Showing
8 changed files
with
93 additions
and
91 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package mcap | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
) | ||
|
||
var ErrBadOffset = errors.New("invalid offset") | ||
var ErrMetadataNotFound = errors.New("metadata not found") | ||
|
||
// ErrNestedChunk indicates the lexer has detected a nested chunk. | ||
var ErrNestedChunk = errors.New("detected nested chunk") | ||
var ErrChunkTooLarge = errors.New("chunk exceeds configured maximum size") | ||
var ErrRecordTooLarge = errors.New("record exceeds configured maximum size") | ||
var ErrInvalidZeroOpcode = errors.New("invalid zero opcode") | ||
|
||
// ErrUnknownSchema is returned when a schema ID is not known to the writer. | ||
var ErrUnknownSchema = errors.New("unknown schema") | ||
|
||
// ErrAttachmentDataSizeIncorrect is returned when the length of a written | ||
// attachment does not match the length supplied. | ||
var ErrAttachmentDataSizeIncorrect = errors.New("attachment content length incorrect") | ||
|
||
var ErrLengthOutOfRange = errors.New("length out of int32 range") | ||
|
||
// ErrUnexpectedToken indicated when an unexpected token was found in an MCAP file. | ||
type ErrUnexpectedToken struct { | ||
err error | ||
} | ||
|
||
func NewErrUnexpectedToken(err error) error { | ||
return &ErrUnexpectedToken{err} | ||
} | ||
|
||
func (e *ErrUnexpectedToken) Error() string { | ||
return e.err.Error() | ||
} | ||
|
||
func (e *ErrUnexpectedToken) Is(target error) bool { | ||
var err *ErrUnexpectedToken | ||
if errors.As(target, &err) { | ||
return true | ||
} | ||
return errors.Is(e.err, target) | ||
} | ||
|
||
// ErrBadMagic indicates invalid magic bytes were detected. | ||
type ErrBadMagic struct { | ||
location magicLocation | ||
actual []byte | ||
} | ||
|
||
func (e *ErrBadMagic) Error() string { | ||
return fmt.Sprintf("Invalid magic at %s of file, found: %v", e.location, e.actual) | ||
} | ||
|
||
func (e *ErrBadMagic) Is(err error) bool { | ||
_, ok := err.(*ErrBadMagic) | ||
return ok | ||
} | ||
|
||
// ErrTruncatedRecord indicates not enough data was available to parse a certain record. | ||
type ErrTruncatedRecord struct { | ||
opcode OpCode | ||
actualLen int | ||
expectedLen uint64 | ||
} | ||
|
||
func (e *ErrTruncatedRecord) Error() string { | ||
if e.expectedLen == 0 { | ||
return fmt.Sprintf( | ||
"MCAP truncated in record length field after %s opcode (%x), received %d bytes", | ||
e.opcode.String(), | ||
byte(e.opcode), | ||
e.actualLen, | ||
) | ||
} | ||
return fmt.Sprintf( | ||
"MCAP truncated in %s (0x%x) record content with expected length %d, data ended after %d bytes", | ||
e.opcode.String(), | ||
byte(e.opcode), | ||
e.expectedLen, | ||
e.actualLen, | ||
) | ||
} | ||
|
||
func (e *ErrTruncatedRecord) Unwrap() error { | ||
return io.ErrUnexpectedEOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package mcap | ||
|
||
// Version of the MCAP library. | ||
var Version = "v1.6.0" | ||
var Version = "v1.7.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters