From 7cf7d9f672f3e1c81f9b62b59018a7fdfd9a8117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Z=C3=A1mb=C3=B3=20Levente?= Date: Thu, 7 Sep 2023 16:46:26 +0200 Subject: [PATCH] create device open error type --- device.go | 4 ++-- error.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/device.go b/device.go index 9ed1a84..32b37da 100644 --- a/device.go +++ b/device.go @@ -59,10 +59,10 @@ func (d *Device) Open(readState bool) (err error) { if d.deviceInfo == nil { return ErrDeviceInfoNotFound } - + d.device, err = d.deviceInfo.Open() if err != nil { - return + return fmt.Errorf("%w, %w", ErrDeviceOpen, err) } d.connected = true diff --git a/error.go b/error.go index c4882dd..d3f992d 100644 --- a/error.go +++ b/error.go @@ -5,6 +5,7 @@ import "errors" // Error types var ( ErrNoDeviceFound = errors.New("no device found") + ErrDeviceOpen = errors.New("cannot connect to device") ErrDeviceInfoNotFound = errors.New("cannot connect to device, device information not found") ErrDeviceNotConnected = errors.New("device is not connected, call Open()") ErrInvalidNumberOfRelays = errors.New("invalid number of relays found")