jobs: Cancel and job.cancel interrupt the running command (#371)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-15 10:39:40 -04:00
1 parent 5fcbee028e
commit 5aace9b5b3
8 files changed
+176 -8

No files matched your search

+26
View File
@@ -79,6 +79,29 @@ pub enum EngineError {
}
impl EngineError {
/// Whether the command stopped because it was cancelled
/// ([`fieldcraft_model::progress::Progress::cancel`]).
pub fn is_cancelled(&self) -> bool {
use fieldcraft_model::Error::Cancelled;
matches!(
self,
EngineError::Model(Cancelled)
| EngineError::Mesh(fieldcraft_mesh::Error::Model(Cancelled))
| EngineError::Solver(fieldcraft_solver::Error::Model(Cancelled))
| EngineError::Explicit(fieldcraft_explicit::Error::Model(Cancelled))
| EngineError::Fluid(fieldcraft_lbm::Error::Model(Cancelled) | fieldcraft_lbm::Error::Mesh(fieldcraft_mesh::Error::Model(Cancelled)))
)
}
/// A body's mesher failure as a parameter problem naming the body, or the cancellation as
/// it is.
pub(crate) fn of_body(body: &str, e: fieldcraft_mesh::Error) -> Self {
match e {
fieldcraft_mesh::Error::Model(fieldcraft_model::Error::Cancelled) => EngineError::Model(fieldcraft_model::Error::Cancelled),
e => EngineError::Params(format!("body `{body}`: {e}")),
}
}
/// A problem with the parameter at `path` (`elastic/young`).
pub fn param(path: impl Into<String>, kind: schema::ProblemKind) -> Self {
Self::Param(schema::Problem::at(path, kind))
@@ -440,6 +463,9 @@ impl Session {
}
}
#[cfg(test)]
mod cancel_tests;
#[cfg(test)]
mod tests {
use super::*;