Skip to content

Commit

Permalink
chore(jans-cedarling): add graceful error handling when init blocking…
Browse files Browse the repository at this point in the history
… client

Signed-off-by: Oleh Bohzok <[email protected]>
  • Loading branch information
olehbozhok committed Jan 7, 2025
1 parent 8ef0802 commit f759ad8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jans-cedarling/cedarling/src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct Cedarling {
impl Cedarling {
/// Builder
pub fn new(config: &BootstrapConfig) -> Result<Cedarling, InitCedarlingError> {
let rt = Runtime::new().unwrap();
let rt = Runtime::new().map_err(InitCedarlingError::RuntimeInit)?;

rt.block_on(AsyncCedarling::new(config))
.map(|async_instance| Cedarling {
Expand Down
4 changes: 4 additions & 0 deletions jans-cedarling/cedarling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ pub enum InitCedarlingError {
/// Error while parse [`BootstrapConfigRaw`]
#[error(transparent)]
BootstrapConfigLoading(#[from] BootstrapConfigLoadingError),
#[cfg(feature = "blocking")]
/// Error while init tokio runtime
#[error(transparent)]
RuntimeInit(std::io::Error),
}

/// The instance of the Cedarling application.
Expand Down

0 comments on commit f759ad8

Please sign in to comment.