Files
photocraft/crates/engine/src/error.rs
T
FredApps 4f23f459ba Merge approved PhotoCraft PR #3464: fix(vector): target selected saved paths and own Pen gestures
Port behavior and regression coverage into current modules; preserve current upstream behavior.
Reconcile captured Pen and Freeform targets with current resumed-subpath, Type Path, Path Operation and draft recovery behavior. Valid source-owned tab switches commit to captured original target; invalid snapshots cancel with a diagnostic; refused commits retain draft and suppress automatic retries. Preserve current Saved(index) API and hidden-work-path protections, register all new ownership/gesture tests and add original-target tab-switch/deleted-target cases. Includes verified compile/API corrections from prior checkpoints.
2026-10-29 06:33:02 +01:00

35 lines
1.3 KiB
Rust

use super::LayerId;
use crate::command_hints;
#[derive(Debug, thiserror::Error)]
pub enum EngineError {
/// Displays with the nearest registered ids, if any ([`command_hints`], #3674).
#[error("unknown command `{id}`{hint}", id = .0, hint = command_hints::unknown_command_hint(.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"))
}
}