Skip to content

Conversation

@jmayclin
Copy link
Contributor

Goal

Use a more specific error type.

Why

We have confusing error types that we use in our testing harnesses.

type Error = Box<dyn std::error::Error>;
type Result<T, E = Error> = core::result::Result<T, E>;

These were then referred to as crate::testing::Error, etc. This was confusing because you then expect them to be test specific errors but they were just wrapped around standard library types.

More specifically, the Box<dyn std::error::Error> is very rarely necessary in our tests, because everything returns a crate::error::Error. We should prefer to use the more description/specific error type as return values for our tests.

How

All tests (except 2) only ever return the crate specific error type. I just used unwraps for the two tests that were working with IO errors.

Testing

Existing CI should pass.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant