Skip to main content

ProcError

Enum ProcError 

Source
pub enum ProcError {
Show 14 variants ProcessNotFound(String), NameNotFound { name: String, in_command_line: usize, }, FilteredOut { target: String, reason: String, }, PortNotFound(u16), PermissionDenied(u32), InvalidInput(String), ConfirmationRequired { message: String, processes: Vec<Process>, not_found: Option<Vec<String>>, }, SystemError(String), Timeout(String), ParseError(String), NotSupported(String), ProcessGone(u32), SignalError(String), Reported { message: String, exit_code: ExitCode, },
}
Expand description

Main error type for proc operations

Variants§

§

ProcessNotFound(String)

No process found matching the given target

§

NameNotFound

No process has this name, but some have it in their command line, which --cmd would match

Fields

§name: String

The name that was looked for

§in_command_line: usize

How many processes have it in their command line (at least one)

§

FilteredOut

A target exists but --in or --by ruled out everything it matched. The target sits in the quotes and the reason follows them.

Fields

§target: String

The target as typed (node, :3000, 1234)

§reason: String

Which filter ruled it out

§

PortNotFound(u16)

No process is listening on the specified port

§

PermissionDenied(u32)

Insufficient permissions to operate on the process

§

InvalidInput(String)

User provided invalid input or arguments

§

ConfirmationRequired

A command that changes processes was run without --yes where nobody can be asked (--json, or no terminal). Carries the processes it would have changed so --json callers can see them in the error.

Not shown as invalid input: the call is valid, it only needs a yes, and the JSON reason (needs_confirmation) says so.

Fields

§message: String

What to pass to proceed

§processes: Vec<Process>

The processes the command would have changed

§not_found: Option<Vec<String>>

The targets that matched nothing, for a command that takes targets (None for one that finds its own processes)

§

SystemError(String)

An underlying system call failed

§

Timeout(String)

The operation exceeded the allowed time limit

§

ParseError(String)

Failed to parse input or system output

§

NotSupported(String)

Feature is not available on the current platform

§

ProcessGone(u32)

The target process terminated during the operation

§

SignalError(String)

Failed to send a signal to the process

§

Reported

The command already printed its result, but the operation did not fully succeed (some processes failed, a port stayed busy, a wait timed out). main exits with exit_code without printing anything further.

Fields

§message: String

Human-readable summary of what did not succeed

§exit_code: ExitCode

Exit code to return

Implementations§

Source§

impl ProcError

Source

pub fn command_line_hint(&self) -> Option<String>

The --cmd hint, when this error carries one

Source

pub fn reason(&self) -> Option<&'static str>

Why this error is exit 4 (nothing was done), as the reason of the JSON error. None for every error with another exit code.

Source

pub fn name_not_found(name: &str, in_command_line: usize) -> Self

The error for a name that matched no process: ProcError::NameNotFound when in_command_line processes have it in their command line (which --cmd would match), ProcError::ProcessNotFound when none do.

Source

pub fn reported(exit_code: ExitCode, message: impl Into<String>) -> Self

Creates a ProcError::Reported for a result that has already been printed.

Trait Implementations§

Source§

impl Debug for ProcError

Source§

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

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

impl Display for ProcError

Source§

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

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

impl Error for ProcError

1.30.0 · 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<&ProcError> for ExitCode

Source§

fn from(err: &ProcError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for ProcError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for ProcError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for ProcError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for ProcError

Source§

fn from(err: 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, !>

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.