Fluere is a powerful and versatile tool designed for network monitoring and analysis. It is capable of capturing network packets in pcap format and converting them into NetFlow data, providing a comprehensive view of network traffic. It also Provides Terminal User Interface.
Apache License 2.0
33
stars
3
forks
source link
Modify error handling to properly exit the program with error messages #34
This PR modifies the error handling in the project to handle errors gracefully, log the error messages, and exit the program properly. The current implementation uses the panic! macro, which is not suitable for a stable release. The changes made in this PR replace the panic! macro with proper error handling, utilize the existing logging system to log error messages, and modify the main function to handle errors returned by the functions it calls.
Summary
Modified src/net/packet_pnet.rs:
Replaced the panic! macro with a return statement that returns a NetError::EmptyPacket error in line 40.
Replaced the panic! macro with a return statement that returns a NetError::UnknownProtocol error in lines 59-63.
Modified src/utils/log.rs:
Added a new method to the Log struct that takes a &str argument and logs it as an error message.
Modified src/net/errors.rs:
Added a new variant to the NetError enum to represent a general error. This variant has a single field of type String to hold the error message.
Modified src/main.rs:
Modified the cli function to handle the errors returned by the functions it calls. If an error is returned, it logs the error message using the log function from the utils module and then exits the program with a non-zero status code.
Fixes #31.
To checkout this PR branch, run the following command in your terminal:
git checkout {pull_request.branch_name}
🎉 Latest mprovements to Sweep:
Getting Sweep to format before committing! Check out Sweep Sandbox Configs to set it up.
We launched our browser extension making it faster to make Sweep issues.
We released a demo of our chunker, where you can find the corresponding blog and code.
💡 To get Sweep to edit this pull request, you can:
Leave a comment below to get Sweep to edit the entire PR
Leave a comment in the code will only modify the file
Edit the original issue to get Sweep to recreate the PR from scratch
Description
This PR modifies the error handling in the project to handle errors gracefully, log the error messages, and exit the program properly. The current implementation uses the panic! macro, which is not suitable for a stable release. The changes made in this PR replace the panic! macro with proper error handling, utilize the existing logging system to log error messages, and modify the main function to handle errors returned by the functions it calls.
Summary
Modified src/net/packet_pnet.rs:
Modified src/utils/log.rs:
Modified src/net/errors.rs:
Modified src/main.rs:
Fixes #31.
To checkout this PR branch, run the following command in your terminal:
🎉 Latest mprovements to Sweep:
💡 To get Sweep to edit this pull request, you can: