Skip to content

Commit

Permalink
feat: better error return types
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiankachlock committed Jul 12, 2024
1 parent 6dd8db0 commit 2fb0ea4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pkg/devices/energy_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (t *TapoEnergyMonitoringPlug) GetDeviceInfo() (response.DeviceInfoPlug, err
if err != nil {
return response.DeviceInfoPlug{}, err
}
return data.Result, nil
return data.Result, data.GetError()
}

// On turns the device on.
Expand Down Expand Up @@ -97,7 +97,7 @@ func (t *TapoEnergyMonitoringPlug) GetDeviceUsage() (response.DeviceUsageEnergyM
if err != nil {
return response.DeviceUsageEnergyMonitor{}, err
}
return data.Result, nil
return data.Result, data.GetError()
}

// GetEnergyUsage returns the energy usage of the device.
Expand All @@ -111,7 +111,7 @@ func (t *TapoEnergyMonitoringPlug) GetEnergyUsage(params request.GetEnergyDataPa
if err != nil {
return response.EnergyUsage{}, err
}
return data.Result, nil
return data.Result, data.GetError()
}

// GetCurrentPower returns the current power usage of the device.
Expand All @@ -125,5 +125,5 @@ func (t *TapoEnergyMonitoringPlug) GetCurrentPower() (response.CurrentPower, err
if err != nil {
return response.CurrentPower{}, err
}
return data.Result, nil
return data.Result, data.GetError()
}
6 changes: 3 additions & 3 deletions pkg/devices/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (t *TapoHub) GetDeviceInfo() (response.DeviceInfoHub, error) {
if err != nil {
return response.DeviceInfoHub{}, err
}
return data.Result, nil
return data.Result, data.GetError()
}

func (t *TapoHub) GetChildDeviceList() (ChildDeviceList, error) {
Expand Down Expand Up @@ -89,7 +89,7 @@ func (t *TapoHub) GetChildDeviceComponentList() (response.ChildDeviceComponentLi
if err != nil {
return response.ChildDeviceComponentList{}, err
}
return data.Result, nil
return data.Result, data.GetError()
}

func getChild(by func(ChildDeviceWrapper) (bool, error), devices []ChildDeviceWrapper) (bool, ChildDeviceWrapper, error) {
Expand Down Expand Up @@ -194,7 +194,7 @@ func (t *TapoHub) GetSupportedAlarms() (response.AlarmsList, error) {
if err != nil {
return response.AlarmsList{}, err
}
return data.Result, nil
return data.Result, data.GetError()
}

func (t *TapoHub) PlayAlarm(alarmType string, volume request.AlarmVolume, duration int) error {
Expand Down

0 comments on commit 2fb0ea4

Please sign in to comment.