chore: better error message for missing mask
Some checks failed
Some checks failed
This commit is contained in:
parent
851e950286
commit
5c55335c61
1 changed files with 5 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue