Closed hnorkowski closed 11 months ago
Hi @hnorkowski, thank you for opening this issue! :) @bits0rcerer has provided a potential fix in #8 – could you try out the latest crate version and check if the problem has been resolved?
@hnorkowski thanks for reporting. As @JKRhb pointed out @bits0rcerer improved the error handling in the helper functions.
I confirmed that your code will not panic and added a test based on your issue: https://github.com/namib-project/nftables-rs/blob/1bd71ea9923ea859b89e90e8c8b795768c5b91ea/tests/helper_tests.rs#L23-L37
Looking at your use case I assume that you want to ensure a table is deleted. An error by nft is expected if you attempt to delete a non-existing table. As a safe way to ensure a table does not exist, you can add instructions to first create the table and then delete it immediately.
This is how we solved this in another project:
We used this strategy to reset a table.
I'm closing this issue, as the #8 should fix it.
Please reopen if this does not work for you.
When I try to delete a table that does not exist the crate panics instead of returning an Result::Err as expected
Example Code:
Error: