stale-kilobyte-24744
10/23/2022, 8:34 AMshutttle_service::main I have (inlined for brevity)
rust
let val = secret_store.get(prop)
.ok_or_else(|| ConfigurationMissingError)
.into_report()
.attach_printable(format!("Could not get {prop} from Secrets"))?
.parse::<u64>()
.map_err(|e| ConfigurationParsingError)
.into_report()
.attach_printable(format!("Could not parse {prop}"))?;
// elsewhere in lib.rs
enum StartupError {
ConfigurationMissingError,
ConfigurationParsingError,
}
it results in
> ? couldn't convert the error to shuttle_service::Error
if I add .map_err(|e| anyhow!("{e}")) I get following instead:
> type mismatch resolving <impl std::future::Future<Output = std::result::Result<std::boxed::Box<(dyn shuttle_service::Service + 'static)>, error_stack::Report<shuttle_service::Error>>> as std::future::Future>::Output == std::result::Result<std::boxed::Box<dyn shuttle_service::Service>, shuttle_service::Error>
EDIT: I've thought about it a bit and I'm over-complicating things, I don't need so much complexity around reading the startup configuration, I can just use `anyhow!`s here, I'm going to do that:
rust
secret_store.get(prop)
.ok_or_else(|| anyhow!("Could not get {prop} from Secrets"))?
.parse::<T>()
.map_err(|e| anyhow!("Could not parse {prop}, {e}"))?
But I'm still curious, what would be the way to fix it.stocky-kangaroo-53672
10/24/2022, 6:45 AM.map_err(CustomError::new)? because CustomError is just an alias for anyhow
https://github.com/shuttle-hq/shuttle/blob/b00671dc32b341ad6dafba0e7ac1fb1b803a68f5/examples/rocket/postgres/src/lib.rs#L44