Skip to content

Commit

Permalink
chore: clarify trait usage in location test
Browse files Browse the repository at this point in the history
Both `WrapErr` and `ContextCompat` expose
`anyhow` compatibility methods.

`ContextCompat` is completely feature gated
behind the `anyhow` flag.

`WrapErr`, on the other hand, feature-gates
individual functions behind the `anyhow` flag.

This has led to [confusion][confusion]
in the past.

[confusion]: eyre-rs#138 (comment)
  • Loading branch information
LeoniePhiline authored and thenorili committed Feb 29, 2024
1 parent e570151 commit f725460
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions eyre/tests/test_location.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::panic::Location;

use eyre::WrapErr;

struct LocationHandler {
actual: Option<&'static str>,
expected: &'static str,
Expand Down Expand Up @@ -46,6 +44,7 @@ fn test_wrap_err() {
Box::new(LocationHandler::new(expected_location))
}));

use eyre::WrapErr;
let err = read_path("totally_fake_path")
.wrap_err("oopsie")
.unwrap_err();
Expand Down Expand Up @@ -75,6 +74,7 @@ fn test_wrap_err_with() {
Box::new(LocationHandler::new(expected_location))
}));

use eyre::WrapErr;
let err = read_path("totally_fake_path")
.wrap_err_with(|| "oopsie")
.unwrap_err();
Expand Down Expand Up @@ -106,6 +106,7 @@ fn test_context() {
Box::new(LocationHandler::new(expected_location))
}));

use eyre::WrapErr;
let err = read_path("totally_fake_path")
.context("oopsie")
.unwrap_err();
Expand All @@ -122,6 +123,7 @@ fn test_with_context() {
Box::new(LocationHandler::new(expected_location))
}));

use eyre::WrapErr;
let err = read_path("totally_fake_path")
.with_context(|| "oopsie")
.unwrap_err();
Expand Down

0 comments on commit f725460

Please sign in to comment.