Engine: a parameter error carries its key and problem (EngineError::Param)

A form can show the problem beside the field it is about. The message
still names the key, as before, for agents.

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-14 20:58:45 -04:00
1 parent 8df4ea040c
commit 9dcbb9c9a6
14 files changed
+60 -49

No files matched your search

+12
View File
@@ -41,6 +41,11 @@ pub enum EngineError {
UnknownCommand(String),
#[error("{0}")]
Params(String),
/// One parameter is missing or wrong: its key (a JSON path, `elastic/young`) and what is
/// wrong with it. The message names the key (agents need it); a form shows the problem
/// beside the field, by its label.
#[error("`{key}` {problem}")]
Param { key: String, problem: String },
#[error(transparent)]
Model(#[from] fieldcraft_model::Error),
#[error(transparent)]
@@ -65,6 +70,13 @@ pub enum EngineError {
Internal { command: String, message: String },
}
impl EngineError {
/// A problem with parameter `key`.
pub fn param(key: impl Into<String>, problem: impl Into<String>) -> Self {
Self::Param { key: key.into(), problem: problem.into() }
}
}
pub type Result<T> = std::result::Result<T, EngineError>;
/// The result of a solved step, from the implicit, the explicit or the lattice Boltzmann solver.