...
This commit is contained in:
@@ -4,16 +4,23 @@ use std::fmt;
|
||||
use std::error::Error;
|
||||
use std::io;
|
||||
|
||||
// Define a custom error type for process operations
|
||||
/// Error type for process management operations
|
||||
///
|
||||
/// This enum represents various errors that can occur during process management
|
||||
/// operations such as listing, finding, or killing processes.
|
||||
#[derive(Debug)]
|
||||
pub enum ProcessError {
|
||||
/// An error occurred while executing a command
|
||||
CommandExecutionFailed(io::Error),
|
||||
/// A command executed successfully but returned an error
|
||||
CommandFailed(String),
|
||||
/// No process was found matching the specified pattern
|
||||
NoProcessFound(String),
|
||||
/// Multiple processes were found matching the specified pattern
|
||||
MultipleProcessesFound(String, usize),
|
||||
}
|
||||
|
||||
// Implement Display for ProcessError
|
||||
/// Implement Display for ProcessError to provide human-readable error messages
|
||||
impl fmt::Display for ProcessError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
@@ -1,2 +1,17 @@
|
||||
//! # Process Module
|
||||
//!
|
||||
//! The `process` module provides functionality for managing and interacting with
|
||||
//! system processes across different platforms. It includes capabilities for:
|
||||
//!
|
||||
//! - Running commands and scripts
|
||||
//! - Listing and filtering processes
|
||||
//! - Killing processes
|
||||
//! - Checking for command existence
|
||||
//!
|
||||
//! This module is designed to work consistently across Windows, macOS, and Linux.
|
||||
|
||||
pub mod run;
|
||||
pub mod mgmt;
|
||||
|
||||
use run::*;
|
||||
use mgmt::*;
|
@@ -7,23 +7,35 @@ use std::fmt;
|
||||
use std::error::Error;
|
||||
use std::io;
|
||||
|
||||
use super::text;
|
||||
use crate::text;
|
||||
|
||||
// Define a custom error type for run operations
|
||||
/// Error type for command and script execution operations
|
||||
///
|
||||
/// This enum represents various errors that can occur during command and script
|
||||
/// execution, including preparation, execution, and output handling.
|
||||
#[derive(Debug)]
|
||||
pub enum RunError {
|
||||
/// The command string was empty
|
||||
EmptyCommand,
|
||||
/// An error occurred while executing a command
|
||||
CommandExecutionFailed(io::Error),
|
||||
/// A command executed successfully but returned an error
|
||||
CommandFailed(String),
|
||||
/// An error occurred while preparing a script for execution
|
||||
ScriptPreparationFailed(String),
|
||||
/// An error occurred in a child process
|
||||
ChildProcessError(String),
|
||||
/// Failed to create a temporary directory
|
||||
TempDirCreationFailed(io::Error),
|
||||
/// Failed to create a script file
|
||||
FileCreationFailed(io::Error),
|
||||
/// Failed to write to a script file
|
||||
FileWriteFailed(io::Error),
|
||||
/// Failed to set file permissions
|
||||
PermissionError(io::Error),
|
||||
}
|
||||
|
||||
// Implement Display for RunError
|
||||
/// Implement Display for RunError to provide human-readable error messages
|
||||
impl fmt::Display for RunError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
Reference in New Issue
Block a user