Files
AstralRinth/packages/modrinth-util/src/lib.rs
aecsocket f8a5a77daa Expose test utils to Labrinth dependents (#4703)
* Expose test utils to Labrinth dependents

* Feature gate `labrinth::test`

* Unify db migrators

* Expose `NotificationBuilder::insert_many_deliveries`

* Add logging utils to common crate

* Remove unused console-subscriber layer

* fix CI
2025-11-08 20:26:24 +00:00

26 lines
642 B
Rust

#![doc = include_str!("../README.md")]
mod error;
pub mod log;
pub use error::*;
use eyre::{Result, eyre};
/// Fetches an environment variable, possibly loading it using [`dotenvy`].
///
/// # Errors
///
/// Errors if the environment variable is missing or empty, providing a
/// pretty-printed error including the environment variable name.
#[track_caller]
pub fn env_var(key: &str) -> Result<String> {
let value = dotenvy::var(key)
.wrap_err_with(|| eyre!("missing environment variable `{key}`"))?;
if value.is_empty() {
Err(eyre!("environment variable `{key}` is empty"))
} else {
Ok(value)
}
}