Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved error handling #5

Open
6 tasks
pulsastrix opened this issue Nov 19, 2022 · 0 comments
Open
6 tasks

Improved error handling #5

pulsastrix opened this issue Nov 19, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@pulsastrix
Copy link
Member

Summary

libcoap-rs currently has rather limited error-handling capabilities. This should be improved.

Description

While libcoap-rs has some error handling support, it falls short in some regards:

  • No library-internal logging
    • The log crate would allow library users to use their own logging framework while still allowing us to provide log output
  • Some errors are silently ignored
    • While message parsing errors are responded to with an RST message, the library user is not informed of such malformed requests. It might be useful if users could provide callbacks/event handlers for such events
  • We might want to re-evaluate if there are some places where we panic even though we should return a Result
  • libcoap is rather limited in its error output: Most functions simply return a value on success and NULL on failure, making it rather hard to pinpoint the exact reason for this error.
    • Fixing this would probably require some large changes in libcoap as we would have to implement error codes throughout the entire library

Implementation steps

  • Add some library-internal logging
    • Integrate the log crate and add logging messages where reasonable
    • Redirect libcoap's own logging to the log crate (see coap_set_log_handler())
  • Add event handler methods for error handling
  • Evaluate all panics
  • (Optional: Add error codes and error code retrieval functions to libcoap)

Related Issues/MRs

@pulsastrix pulsastrix added the enhancement New feature or request label Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant