lua-mosquitto icon indicating copy to clipboard operation
lua-mosquitto copied to clipboard

handle lookup errors when connecting

Open ncopa opened this issue 2 years ago • 3 comments

Connect may result in lookup error, which was not handled. Solve this by use a default error handler which returns whatever mosquitto reports.

This prevents us from missing errors.

ncopa avatar Jun 12 '23 13:06 ncopa

Given that we still have some of the error codes enumerated, would it perhaps make more sense to leave the others that were enumerated, and just add a default case, perhaps with a "warning, missing enums in library handling!" ?

karlp avatar Jun 12 '23 14:06 karlp

The idea was to only handle the special cases:

  • success
  • errno
  • errors that should raise a lua error

And then just returns the error number with the mosquitto_strerror as default.

This helps us to deal with undocumented errors (like no connection) and future errors.

I dont think we need a warning for it.

One question though, I don't know we we should raise a lua error by default or return the error number.

ncopa avatar Jun 12 '23 15:06 ncopa

Given that we still have some of the error codes enumerated, would it perhaps make more sense to leave the others that were enumerated, and just add a default case, perhaps with a "warning, missing enums in library handling!" ?

Rebased it to do this, but I have no idea how to do the warning.

@karlp can you please have another look?

ncopa avatar Jun 16 '23 13:06 ncopa