chore: better error message for missing mask
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
andig 2024-03-13 12:24:14 +01:00
parent 851e950286
commit 5c55335c61

View file

@ -3,6 +3,7 @@ package modbus
import (
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"strconv"
"strings"
@ -12,6 +13,10 @@ import (
func decodeMask(mask string) (uint64, error) {
mask = strings.ToLower(mask)
if mask == "" {
return 0, errors.New("mask is required")
}
if strings.HasPrefix(mask, "0x") {
if len(mask) < 3 {
return 0, fmt.Errorf("invalid mask: %s", mask)