Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spawner): narrow error type #18

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions crates/spuz_spawner/src/err.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/spuz_spawner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ use tokio::process::Command;
use tracing::debug;

pub use crate::{
err::{Error, Result},
layer::{LaunchMod, Layer},
process::LaunchCommand,
};

pub mod compose;
mod err;
mod layer;
mod process;
#[cfg(feature = "useful-layers")]
Expand Down
12 changes: 10 additions & 2 deletions crates/spuz_spawner/src/process.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use async_channel::Receiver;
use thiserror::Error;
use tokio::process::Command;
#[cfg(feature = "process-handle")]
use {
crate::Result,
async_channel::unbounded,
std::sync::Arc,
tokio::{io::AsyncReadExt, sync::Notify},
Expand All @@ -23,7 +23,7 @@ impl LaunchCommand {
}

#[cfg(feature = "process-handle")]
pub fn spawn(self) -> Result<ProcessHandle> {
pub fn spawn(self) -> Result<ProcessHandle, SpawnError> {
let mut cmd = self.into_command();
let mut child = cmd.spawn()?;
// # SAFETY
Expand Down Expand Up @@ -95,3 +95,11 @@ pub struct ProcessHandle {
pub exit: Arc<Notify>,
pub logs: Receiver<String>,
}

#[derive(Debug, Error)]
#[error("Failed to spawn process: {source}")]
pub struct SpawnError {
#[from]
#[source]
source: std::io::Error,
}