use thiserror::Error;
#[derive(Clone, Debug, PartialEq, Eq, Error)]
pub enum RenderError {
#[error(
"the parameter set names `{parameter}`, which command `{command}` does not declare; a \
value nothing consumes is a value nobody reviewed"
)]
ArgumentUndeclared {
command: String,
parameter: String,
},
#[error(
"the parameter set omits `{parameter}`, which command `{command}` declares and gives no \
default; there is nothing for this surface to invent"
)]
ArgumentMissing {
command: String,
parameter: String,
},
#[error(
"parameter `{parameter}` of command `{command}` is declared a {declared}, and the \
parameter set supplies a {supplied}"
)]
ArgumentTypeMismatch {
command: String,
parameter: String,
observed: String,
declared: &'static str,
supplied: &'static str,
},
#[error(
"command `{command}` would emit `{element}` for argument `{argument}`, which begins with \
`-`, and no `{marker}` argument stands before it. Nothing downstream could tell it from \
an option"
)]
LeadingDashOperand {
command: String,
argument: String,
element: String,
marker: &'static str,
},
#[error(
"command `{command}` is written to put the value of `{parameter}` into one of its \
arguments, but the command declares no parameter of that name, so there is nothing \
anywhere that could fill it and no argument list to run; redeploying the document under \
the current spelling re-derives a command whose body and parameters agree"
)]
UnboundHole {
command: String,
parameter: String,
},
#[error(
"command `{command}` was deployed under a prior archive form and carries {construct}, \
which the current form does not express; the archive still reads and lists everywhere, \
and redeploying the document under the current spelling makes the command runnable again"
)]
PriorFormUnrenderable {
command: String,
construct: String,
},
#[error(
"parameter `{parameter}` is {kind}, which has no unambiguous command-argument form; \
supply a string, number, or boolean"
)]
UnrepresentableValue {
parameter: String,
kind: &'static str,
},
#[error(
"parameter `{parameter}` contains a NUL byte, which cannot appear in a command argument"
)]
InteriorNul {
parameter: String,
},
}
#[must_use]
pub const fn shape_word(list: bool) -> &'static str {
if list { "list" } else { "single value" }
}