mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 09:26:43 +00:00
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.
35 lines
1.3 KiB
Rust
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"))
|
|
}
|
|
}
|