Hundemeier / go-sacn

Implementation of the sACN aka ANSI E1.31 protocol for streaming DMX-data in go
MIT License
16 stars 9 forks source link

Why panic for errors? #15

Open Orygin opened 1 year ago

Orygin commented 1 year ago

Hello,

I have been using this lib and it works great, except when something unexpected happen and the lib crashes my program completely. (For example, putting the computer to sleep, breaks the socket and panics).

I saw 6 panics in the code, and 3 of them could be simply passed up the function to the caller to be handled. The 3 others happen inside goroutines running to send/receive data, and will need special handling from there.

Imo, there should be a way to handle these errors externally, so that we have full control over errors happening during execution. But, changing the functions which could return an error to the user would result in an api break, and returning errors from the Rx/Tx goroutines would necessitate a new way to get them to the library user.

I would be willing to put the work for implementing those changes, but I would like inputs about the best ways to proceed. The simplest way I see is having a callback called when an universe/socket is stopped because of an error, letting the user know of the issue and letting them reconnect.

Thanks for your opinions