Files
photocraft/crates/engine/src/error.rs
T

33 lines
1.1 KiB
Rust

use super::*;
#[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"))
}
}