Skip to content

Commit b162768

Browse files
ldanilekConvex, Inc.
authored andcommitted
improve anyhow error contexts (#26829)
GitOrigin-RevId: 3eb75b10d67b3586422c877b27735c56e4f69c44
1 parent aff50f7 commit b162768

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

crates/application/src/application_function_runner/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl<RT: Runtime> FunctionRouter<RT> {
288288
let (tx, outcome) = self
289289
.function_runner_execute(tx, path_and_args, udf_type, journal, context, None)
290290
.await?;
291-
let tx = tx.context("Missing transaction in response for {udf_type}")?;
291+
let tx = tx.with_context(|| format!("Missing transaction in response for {udf_type}"))?;
292292
timer.finish();
293293
Ok((tx, outcome))
294294
}

crates/common/src/components/component_definition_path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl FromStr for ComponentDefinitionPath {
4646
PathComponent::Normal(c) => {
4747
let s = c
4848
.to_str()
49-
.context("Path {s} has an invalid Unicode character")?;
49+
.with_context(|| format!("Path {s} has an invalid Unicode character"))?;
5050
check_valid_path_component(s)?;
5151
},
5252
// Component paths are allowed to have `..` (since they're relative from the root
@@ -60,7 +60,7 @@ impl FromStr for ComponentDefinitionPath {
6060
}
6161
path.as_os_str()
6262
.to_str()
63-
.context("Path {s} has an invalid Unicode character")?;
63+
.with_context(|| format!("Path {s} has an invalid Unicode character"))?;
6464
Ok(ComponentDefinitionPath { path })
6565
}
6666
}

crates/convex/sync_types/src/timestamp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl Timestamp {
4343
let nanos = self
4444
.0
4545
.checked_add(duration.as_nanos() as u64)
46-
.context("timestamp {self} + {duration:?} overflow u64")?;
46+
.with_context(|| format!("timestamp {self} + {duration:?} overflow u64"))?;
4747

4848
anyhow::ensure!(
4949
nanos <= u64::from(Self::MAX),

0 commit comments

Comments
 (0)