Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { Timeout { waiting_for: String, timeout: Duration, screen: Screen, }, Eof { waiting_for: String, screen: Screen, }, Spawn { command: String, reason: String, }, Pty(String), Io(Error), Size(String), Emulator { detail: String, screen: Screen, }, Input(String), Parse(String), Write { what: Box<str>, screen: Screen, }, }
Expand description

Errors returned by Terminal operations.

§TERMLENS_ARTIFACT_DIR

Every variant that carries a Screen prints it, so a CI log shows what the application displayed. When the environment variable TERMLENS_ARTIFACT_DIR names a directory, the same screen is also written there as it is embedded: <test>-<n>.screen.json with the serde feature, <test>-<n>.screen.txt (the with_styles rendering, which Screen::parse reads back) without, where <test> is the current thread’s name — under cargo test, the test’s path. Unset, the hook is one environment read and nothing else; insta’s .snap.new files stay where insta puts them. This repository’s report action (.github/actions/report) renders that directory into a pull request’s step summary.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Timeout

A wait_* call ran past its deadline. The screen at the moment of the timeout is embedded and printed, so a CI log alone is enough to see what the application was actually showing.

Fields

§waiting_for: String

Human description of what was awaited.

§timeout: Duration

The deadline that expired.

§screen: Screen

The screen when the deadline expired.

§

Eof

The PTY reached end-of-file (the child exited or closed its terminal) while a wait’s condition was still unmet. Waiting longer can never succeed, so this fails fast instead of burning the full timeout.

Fields

§waiting_for: String

Human description of what was awaited.

§screen: Screen

The final screen contents.

§

Spawn

Spawning the child process failed.

Fields

§command: String

The command line that failed to spawn.

§reason: String

The underlying PTY/OS error.

§

Pty(String)

A PTY control operation (open, resize, reader/writer setup) failed.

§

Io(Error)

An OS-level I/O error (e.g. while waiting on the child process).

§

Size(String)

A terminal size argument is invalid and was rejected before anything was spawned or sent to the child.

§

Emulator

The VT emulator panicked while processing the child’s output, so the grid stopped advancing at the screen embedded here.

The emulation runs on the reader thread, where a panic propagates nowhere: before this existed the drain simply died, every later snapshot returned the same frozen screen, and each wait ran to its deadline reporting a predicate that was never going to become true. A wait now fails immediately and says why. The screen is the last one taken before the failure — the emulator is not asked again, because its state after a panic means nothing.

Fields

§detail: String

The panic message from the emulator.

§screen: Screen

The last screen taken before the emulator failed.

§

Input(String)

Typed input or control the child cannot receive — e.g. a mouse click while the application never enabled mouse tracking (sending it anyway would feed the app bytes it would misparse as garbage keys), or a signal to a child that has already been reaped (its pid may belong to someone else by now).

§

Parse(String)

A saved screen could not be read back by Screen::parse: the text is not the snapshot format of docs/DESIGN.md §3. The message names the line.

§

Write

Typed input could not be delivered: the child is gone and the OS tore the terminal down, or it stopped reading its input and the write gave up at the terminal’s deadline rather than blocking forever.

Distinct from Error::Input on purpose. Input means the application cannot make sense of these bytes — a test bug. This means the bytes could not be handed over at all, which is a fact about the child rather than about the test, so the screen at the moment of the failure is embedded the way a timeout’s is.

Fields

§what: Box<str>

What was being sent, which command it was going to, and why the write failed.

§screen: Screen

The screen when the write failed.

Implementations§

Source§

impl Error

Source

pub fn screen(&self) -> Option<&Screen>

The screen embedded in Error::Timeout, Error::Eof, Error::Emulator or Error::Write, if any.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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 Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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.