error.scoped.ScopeError
Rust
- Python Unavailable
- Ruby Unavailable
- Lua Unavailable
- TypeScript Unavailable
- Rust
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
- Module
- error.scoped
- Package
- libtmux
- Source
- crates/libtmux/src/error/scoped.rs
-
A scoped resource's creation, operation, or cleanup failure.
Returned by
crate::Server::with_session,crate::Session::with_window, andcrate::Window::with_pane. The operation error keeps its original type and value, with no `From<Error>requirement. Cleanup failures retain because creation succeeded; an operation error alone makes no replay guarantee. retains the operation's own result too: it already computedTwhen cleanup failed, and matching the variant is the only way to reach it, since the outerResultisErr` either way.Debug,Display, andstd::error::Errorare implemented for everyTandE, but each only shows a value when its type supports it:DebugneedsT: DebugandE: Debug,DisplayneedsE: Display, andErrorneeds both, since it requires them as supertraits. A caller whose types have neither still gets a working scope: both values remain reachable by matching the variant, and creation and cleanup failures format and chain regardless.std::error::Error::sourceexposes the cleanup error inSelf::CleanupandSelf::OperationAndCleanup, and the creation error inSelf::Creation. It never exposes the operation error:Eneed not implementstd::error::Errorat all, so there is no&(dyn Error + 'static)to hand back even whenDisplaycan show it. Match the variant to reach it directly.Examples
use libtmux::ScopeError;let guard = libtmux::test::TestServer::new().await?;let outcome = guard.server().with_session("work", async |_session| {Err::<(), _>("operation failed")}).await;assert!(matches!(outcome, Err(ScopeError::Operation("operation failed"))));guard.shutdown().await?;
7 declared, 0 inherited
Members
- into_operation method Take the operation's own error, when the operation is what failed.
- into_value method Take the value the operation produced before cleanup failed.
- tmux_error method Borrow the tmux error from creation or cleanup.
- Cleanup constant The operation succeeded, but cleanup failed after creation.
- Creation constant The resource could not be created; the operation did not run.
- Operation constant The operation failed and cleanup succeeded.
- OperationAndCleanup constant The operation and cleanup both failed.