Files
photocraft/crates/engine/src/error.rs
T
Dylan M. Taylor 051ee2aff7 Split oversized functions and fix imports in photocraft crates
Moves code into named helpers (PSD export blocks, key-shortcut stages, options-bar
tool controls, liquify wheel handling, CAF options bar) without changing behaviour,
and restores imports left unfinished in the engine and UI crates. Clippy still
reports cognitive-complexity errors in ui-egui; those are being split next.
2026-10-27 21:43:48 +00:00

33 lines
1.1 KiB
Rust

use super::LayerId;
#[derive(Debug, thiserror::Error)]
pub enum EngineError {
#[error("unknown command `{0}`")]
UnknownCommand(String),
#[error("command `{0}` is not available right now: {1}")]
Disabled(String, String),
#[error("invalid parameters for `{cmd}`: {msg}")]
BadParams { cmd: String, msg: String },
#[error("no active document")]
NoDocument,
#[error("no such layer {0:?}")]
NoLayer(LayerId),
/// [`Self::NoLayer`] as a command reports it: with the layers the document does have, as
/// ids are not positions (#5058).
#[error("no such layer {}; {known}", id.0)]
UnknownLayer { id: LayerId, known: String },
#[error("{0}")]
Other(String),
/// A background job was cancelled (see [`jobs`]); nothing changed.
#[error("cancelled")]
Cancelled,
}
pub type Result<T> = std::result::Result<T, EngineError>;
impl From<photocraft_raster::AllocationError> for EngineError {
fn from(error: photocraft_raster::AllocationError) -> Self {
Self::Other(format!("not enough memory for this operation ({error}); the document was not changed"))
}
}