add most basic error handling on the decode side

This commit is contained in:
2024-12-23 23:59:11 -06:00
parent 0c297d606d
commit 6bc6fb3668
15 changed files with 227 additions and 84 deletions
+9 -6
View File
@@ -9,16 +9,19 @@ type InfoSystemNameChunk struct {
Data InfoSystemNameChunkData
}
func DecodeInfoSystemNameChunk(bytes []byte) InfoSystemNameChunk {
chunk := DecodeChunk(bytes)
system_name := string(chunk.ChunkData[0:chunk.Header.DataLen])
func DecodeInfoSystemNameChunk(bytes []byte) (InfoSystemNameChunk, error) {
chunk, err := DecodeChunk(bytes)
if err != nil {
return InfoSystemNameChunk{}, err
}
data := InfoSystemNameChunkData{}
data := InfoSystemNameChunkData{
SystemName: system_name,
if chunk.Header.DataLen > 0 {
data.SystemName = string(chunk.ChunkData[0:chunk.Header.DataLen])
}
return InfoSystemNameChunk{
Chunk: chunk,
Data: data,
}
}, nil
}