Skip to content

Commit 70e4187

Browse files
committed
graph: Make error checking for EnvVarsMapping possible
1 parent 6b95d96 commit 70e4187

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

graph/src/env/mappings.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ impl fmt::Debug for EnvVarsMapping {
8282
}
8383
}
8484

85-
impl From<InnerMappingHandlers> for EnvVarsMapping {
86-
fn from(x: InnerMappingHandlers) -> Self {
87-
Self {
85+
impl TryFrom<InnerMappingHandlers> for EnvVarsMapping {
86+
type Error = anyhow::Error;
87+
88+
fn try_from(x: InnerMappingHandlers) -> Result<Self, Self::Error> {
89+
let vars = Self {
8890
entity_cache_dead_weight: x.entity_cache_dead_weight.0,
8991
entity_cache_size: x.entity_cache_size_in_kb * 1000,
9092

@@ -102,7 +104,8 @@ impl From<InnerMappingHandlers> for EnvVarsMapping {
102104
allow_non_deterministic_ipfs: x.allow_non_deterministic_ipfs.0,
103105
disable_declared_calls: x.disable_declared_calls.0,
104106
store_errors_are_nondeterministic: x.store_errors_are_nondeterministic.0,
105-
}
107+
};
108+
Ok(vars)
106109
}
107110
}
108111

graph/src/env/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl EnvVars {
268268
pub fn from_env() -> Result<Self, anyhow::Error> {
269269
let inner = Inner::init_from_env()?;
270270
let graphql = InnerGraphQl::init_from_env()?.into();
271-
let mapping_handlers = InnerMappingHandlers::init_from_env()?.into();
271+
let mapping_handlers = InnerMappingHandlers::init_from_env()?.try_into()?;
272272
let store = InnerStore::init_from_env()?.try_into()?;
273273
let ipfs_request_timeout = match inner.ipfs_request_timeout {
274274
Some(timeout) => Duration::from_secs(timeout),

0 commit comments

Comments
 (0)