Skip to main content

SysprimsError

Enum SysprimsError 

Source
pub enum SysprimsError {
    InvalidArgument {
        message: String,
    },
    SpawnFailed {
        source: Error,
    },
    Timeout,
    PermissionDenied {
        pid: u32,
        operation: String,
    },
    NotFound {
        pid: u32,
    },
    NotFoundCommand {
        command: String,
    },
    PermissionDeniedCommand {
        command: String,
    },
    PermissionDeniedPath {
        path: String,
        operation: String,
    },
    NotSupported {
        feature: String,
        platform: String,
    },
    GroupCreationFailed {
        message: String,
    },
    System {
        message: String,
        errno: i32,
    },
    Internal {
        message: String,
    },
}
Expand description

Canonical error type for all sysprims operations.

This is the single error type used across the sysprims ecosystem. It maps cleanly to FFI error codes and provides structured context for programmatic handling.

§FFI Error Code Mapping

VariantFFI Code
InvalidArgumentSYSPRIMS_ERR_INVALID_ARGUMENT (1)
SpawnFailedSYSPRIMS_ERR_SPAWN_FAILED (2)
TimeoutSYSPRIMS_ERR_TIMEOUT (3)
PermissionDeniedSYSPRIMS_ERR_PERMISSION_DENIED (4)
NotFoundSYSPRIMS_ERR_NOT_FOUND (5)
NotSupportedSYSPRIMS_ERR_NOT_SUPPORTED (6)
GroupCreationFailedSYSPRIMS_ERR_GROUP_CREATION_FAILED (7)
SystemSYSPRIMS_ERR_SYSTEM (8)
InternalSYSPRIMS_ERR_INTERNAL (99)

Variants§

§

InvalidArgument

Invalid argument provided.

Returned when input validation fails (e.g., pid = 0, empty command).

Fields

§message: String

Description of what was invalid.

§

SpawnFailed

Failed to spawn a child process.

Wraps the underlying IO error from process creation.

Fields

§source: Error

The underlying IO error.

§

Timeout

Operation timed out.

The child process did not complete within the deadline.

§

PermissionDenied

Permission denied for the operation.

Typically returned when signaling a process owned by another user.

Fields

§pid: u32

The process ID we attempted to operate on.

§operation: String

The operation that was denied (e.g., “terminate”, “signal”).

§

NotFound

Target process not found.

The specified PID does not exist or has already exited.

Fields

§pid: u32

The process ID that was not found.

§

NotFoundCommand

Command not found.

The specified command could not be found in PATH.

Fields

§command: String

The command that was not found.

§

PermissionDeniedCommand

Permission denied for command execution.

The specified command exists but cannot be executed (e.g., not executable).

Fields

§command: String

The command that could not be executed.

§

PermissionDeniedPath

Permission denied for a filesystem path.

Used when opening caller-provided paths such as nohup output targets.

Fields

§path: String

The path that could not be accessed.

§operation: String

The operation that was denied.

§

NotSupported

Operation not supported on the current platform.

Some operations are platform-specific (e.g., killpg on Windows).

Fields

§feature: String

The feature that is not supported.

§platform: String

The platform where it’s not supported.

§

GroupCreationFailed

Failed to create process group or job object.

On Unix, this means setpgid() failed. On Windows, this means Job Object creation failed.

Fields

§message: String

Description of what failed.

§

System

System-level error with errno/GetLastError context.

Used when a syscall fails with an unexpected error code.

Fields

§message: String

Description of the error.

§errno: i32

The errno value (Unix) or GetLastError (Windows).

§

Internal

Internal error (should not happen in normal operation).

Indicates a bug in sysprims or unexpected system state.

Fields

§message: String

Description of the internal error.

Implementations§

Source§

impl SysprimsError

Source

pub fn error_code(&self) -> i32

Get the FFI error code for this error.

Maps to SysprimsErrorCode enum in C-ABI.

Source§

impl SysprimsError

Source

pub fn invalid_argument(message: impl Into<String>) -> Self

Create an InvalidArgument error.

Source

pub fn spawn_failed_io(source: Error) -> Self

Create a SpawnFailed error from an IO error.

Source

pub fn permission_denied(pid: u32, operation: impl Into<String>) -> Self

Create a PermissionDenied error.

Source

pub fn not_found(pid: u32) -> Self

Create a NotFound error.

Source

pub fn not_found_command(command: impl Into<String>) -> Self

Create a NotFoundCommand error.

Source

pub fn permission_denied_command(command: impl Into<String>) -> Self

Create a PermissionDeniedCommand error.

Source

pub fn permission_denied_path( path: impl Into<String>, operation: impl Into<String>, ) -> Self

Create a path-oriented permission denied error.

Source

pub fn spawn_failed( command: impl Into<String>, reason: impl Into<String>, ) -> Self

Create a SpawnFailed error with a command and reason.

Source

pub fn not_supported( feature: impl Into<String>, platform: impl Into<String>, ) -> Self

Create a NotSupported error.

Source

pub fn group_creation_failed(message: impl Into<String>) -> Self

Create a GroupCreationFailed error.

Source

pub fn system(message: impl Into<String>, errno: i32) -> Self

Create a System error.

Source

pub fn internal(message: impl Into<String>) -> Self

Create an Internal error.

Trait Implementations§

Source§

impl Debug for SysprimsError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SysprimsError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for SysprimsError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for SysprimsError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.