2
0
mirror of https://github.com/OrbTools/OrbCommon synced 2024-11-18 03:25:32 +00:00

xdr: panic on error

This commit is contained in:
Minizbot2012 2021-07-28 09:07:30 -04:00
parent 44981a1c33
commit 8260d80249
No known key found for this signature in database
GPG Key ID: 977C8ADE12361917

View File

@ -20,7 +20,10 @@ func init() {
for _, file := range files {
dev := new(DeviceDef)
data, _ := df.ReadFile("xdr/" + file.Name())
xdr.Unmarshal(bytes.NewReader(data), dev)
_, err xdr.Unmarshal(bytes.NewReader(data), dev)
if err!=nil {
panic(err.Error())
}
DeviceTypes[strings.Split(file.Name(), ".")[0]] = dev
}
}
@ -28,7 +31,10 @@ func init() {
//LoadKeymap Load Orbmap KM structure
func LoadKeymap(file io.ReadCloser, dev *DeviceDef) *KeyMap {
mapped := new(KeyMap)
xdr.Unmarshal(file, mapped)
_, err := xdr.Unmarshal(file, mapped)
if err != nil {
panic(err.Error())
}
file.Close()
return mapped
}