shamblett / coap

A Coap package for dart
Other
16 stars 13 forks source link

How is error handling supposed to work? #41

Closed Sorunome closed 1 year ago

Sorunome commented 2 years ago

I am having some trouble trying to grasp how error handling is supposed to work. If sending a message times out, client.send() returns and empty response, instead throwing a timeout exception.

When establishing a UDP connection fails, the error is cought (for logging), but never re-thrown. One could say that this is because your internet may be bad currently and it may be able to establish the connection later on, however it is never retried.

Maybe there is some fundamental concept of error in this package handling that i am missing?

shamblett commented 2 years ago

AS the README says this package is a port of the C# .NET project CoAP .NET so it pretty much follows what that did, if it threw an exception we will, if it logged we will etc. There are some differences caused by dart not supporting exactly what .NET does but in the main it should do the same.

If your asking is there an overall strategy of when we throw, log or retry then no.

Sorunome commented 2 years ago

If your asking is there an overall strategy of when we throw, log or retry then no.

is there any chance this could be improved? Would you accept a PR for that, after discussing how things could look like?

shamblett commented 2 years ago

Yes no problem. One large improvement would to be consistent in what we do across the whole package.

JosefWN commented 2 years ago

Yeah, +1 for consistency! I suppose it's a contentious topic, but in line with how standard libraries work, I typically only handle internal errors in my libraries (and perhaps debug logging at most). This leaves the user of the library to implement API-level error handling and logging at large, making it streamlined with the rest of their application.

shamblett commented 1 year ago

Believe this has been addressed. Package re released at version 5.0.0.