mirror of
https://github.com/jwetzell/psn-go.git
synced 2026-09-10 00:29:47 +00:00
add most basic error handling on the decode side
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user