Skip to content

Commit a4df9cc

Browse files
'buck2_re_configuration': remove anyhow usage
Summary: ^ Reviewed By: iguridi Differential Revision: D65311904 fbshipit-source-id: f0595ebb03426d2ee1884747f80ae7e730397c0b
1 parent 583ba2f commit a4df9cc

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

app/buck2_re_configuration/BUCK

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ rust_library(
66
name = "buck2_re_configuration",
77
srcs = glob(["src/**/*.rs"]),
88
deps = [
9-
"fbsource//third-party/rust:anyhow",
109
"//buck2/allocative/allocative:allocative",
1110
"//buck2/app/buck2_common:buck2_common",
1211
"//buck2/app/buck2_core:buck2_core",
12+
"//buck2/app/buck2_error:buck2_error",
1313
],
1414
)

app/buck2_re_configuration/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ version = "0.1.0"
88

99
[dependencies]
1010
allocative = { workspace = true }
11-
anyhow = { workspace = true }
1211
buck2_common = { workspace = true }
1312
buck2_core = { workspace = true }
13+
buck2_error = { workspace = true }
1414

1515
[lints.rust]
1616
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(fbcode_build)"] }

app/buck2_re_configuration/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static BUCK2_RE_CLIENT_CFG_SECTION: &str = "buck2_re_client";
2121
/// We put functions here that both things need to implement for code that isn't gated behind a
2222
/// fbcode_build or not(fbcode_build)
2323
pub trait RemoteExecutionStaticMetadataImpl: Sized {
24-
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> anyhow::Result<Self>;
24+
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> buck2_error::Result<Self>;
2525
fn cas_semaphore_size(&self) -> usize;
2626
}
2727

@@ -79,7 +79,7 @@ mod fbcode {
7979
}
8080

8181
impl RemoteExecutionStaticMetadataImpl for RemoteExecutionStaticMetadata {
82-
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> anyhow::Result<Self> {
82+
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> buck2_error::Result<Self> {
8383
Ok(Self {
8484
cas_address: legacy_config.parse(BuckconfigKeyRef {
8585
section: BUCK2_RE_CLIENT_CFG_SECTION,
@@ -249,7 +249,7 @@ mod not_fbcode {
249249
pub struct RemoteExecutionStaticMetadata(pub Buck2OssReConfiguration);
250250

251251
impl RemoteExecutionStaticMetadataImpl for RemoteExecutionStaticMetadata {
252-
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> anyhow::Result<Self> {
252+
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> buck2_error::Result<Self> {
253253
Ok(Self(Buck2OssReConfiguration::from_legacy_config(
254254
legacy_config,
255255
)?))
@@ -313,7 +313,7 @@ pub struct HttpHeader {
313313
}
314314

315315
impl FromStr for HttpHeader {
316-
type Err = anyhow::Error;
316+
type Err = buck2_error::Error;
317317

318318
fn from_str(s: &str) -> Result<Self, Self::Err> {
319319
let mut iter = s.split(':');
@@ -322,7 +322,8 @@ impl FromStr for HttpHeader {
322322
key: key.trim().to_owned(),
323323
value: value.trim().to_owned(),
324324
}),
325-
_ => Err(anyhow::anyhow!(
325+
_ => Err(buck2_error::buck2_error!(
326+
[],
326327
"Invalid header (expect exactly one `:`): `{}`",
327328
s
328329
)),
@@ -331,7 +332,7 @@ impl FromStr for HttpHeader {
331332
}
332333

333334
impl Buck2OssReConfiguration {
334-
pub fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> anyhow::Result<Self> {
335+
pub fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> buck2_error::Result<Self> {
335336
// this is used for all three services by default, if given; if one of
336337
// them has an explicit address given as well though, use that instead
337338
let default_address: Option<String> = legacy_config.parse(BuckconfigKeyRef {

0 commit comments

Comments
 (0)