Skip to content

Commit

Permalink
create device open error type
Browse files Browse the repository at this point in the history
  • Loading branch information
lyimmi committed Sep 7, 2023
1 parent 40244a3 commit 7cf7d9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7cf7d9f

Please sign in to comment.