PanicOnError implemented

This commit is contained in:
Tordarus 2025-02-02 22:33:24 +01:00
parent db413ce145
commit 12c700a5c5
3 changed files with 12 additions and 0 deletions

View File

@ -14,6 +14,7 @@ func (api *Api) GetDevices(siteID model.SiteID) (<-chan *model.Device, <-chan er
go func() {
defer close(out)
defer close(errChan)
for page := 1; ; page++ {
resp, err := api.getDevices(page, siteID)

View File

@ -14,6 +14,7 @@ func (api *Api) GetSites() (<-chan *model.Site, <-chan error) {
go func() {
defer close(out)
defer close(errChan)
for page := 1; ; page++ {
resp, err := api.getSites(page)

10
utils.go Normal file
View File

@ -0,0 +1,10 @@
package omadaapi
func PanicOnError[T any](valueChan <-chan T, errChan <-chan error) <-chan T {
go func() {
for err := range errChan {
panic(err)
}
}()
return valueChan
}