Improving error handling and logging in the server loop #2916
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
First time open-source contributor here 🤗
I have been learning Rust for a few months and loved the language. After covering the book I started looking for an interesting project to contribute to. Since I have been using working with backend framework for a few years in other languages, I came to like Axum. I am looking for a way to be useful to the project, starting in the simplest way possible.
Hence this PR is simply an attempt to improve error visibility.
Solution
Replaced the usage of
unwrap_or_else
withpoll_fn
and amatch
statement to ensure errors are logged and handled appropriately rather than panicking or proceeding without full error context.Introduced better error logging with the error! macro when service creation fails, improving visibility when something goes wrong during the
make_service
call.Added
trace
logging to capture connection errors for better debugging of networking issues, which would otherwise be difficult to trace.First timers make plenty of mistakes, I am happy to learn!
Thanks for the good work 👍🏽