#[cfg(feature = "error_reporting")]
use peace::miette::{self, SourceSpan};
use crate::ShCmd;
#[cfg_attr(feature = "error_reporting", derive(peace::miette::Diagnostic))]
#[derive(Debug, thiserror::Error)]
pub enum ShCmdError {
#[error("Failed to execute command: `{}`", sh_cmd)]
#[cfg_attr(
feature = "error_reporting",
diagnostic(code(peace_item_spec_sh_cmd::cmd_exec_fail))
)]
CmdExecFail {
sh_cmd: ShCmd,
#[cfg(feature = "error_reporting")]
#[source_code]
sh_cmd_string: String,
#[source]
error: std::io::Error,
},
#[error("Command produced non-UTF-8 stdout output: `{}`", sh_cmd)]
#[cfg_attr(
feature = "error_reporting",
diagnostic(code(peace_item_spec_sh_cmd::stdout_non_utf8)),
help(
"Update the command to something that outputs UTF8: `{}`\n\
Perhaps encode the output using `base64`",
sh_cmd
)
)]
StdoutNonUtf8 {
sh_cmd: ShCmd,
#[cfg_attr(feature = "error_reporting", source_code)]
stdout_lossy: String,
#[cfg(feature = "error_reporting")]
#[label]
invalid_span: SourceSpan,
#[source]
error: std::str::Utf8Error,
},
#[error("Command produced non-UTF-8 stderr output: `{}`", sh_cmd)]
#[cfg_attr(
feature = "error_reporting",
diagnostic(code(peace_item_spec_sh_cmd::stderr_non_utf8)),
help(
"Update the command to something that outputs UTF8: `{}`\n\
Perhaps encode the output using `base64`",
sh_cmd
)
)]
StderrNonUtf8 {
sh_cmd: ShCmd,
#[cfg_attr(feature = "error_reporting", source_code)]
stderr_lossy: String,
#[cfg(feature = "error_reporting")]
#[label]
invalid_span: SourceSpan,
#[source]
error: std::str::Utf8Error,
},
#[error(
r#"Ensure check shell command did not return "true" or "false": `{}`"#,
sh_cmd
)]
#[cfg_attr(
feature = "error_reporting",
diagnostic(code(peace_item_spec_sh_cmd::ensure_check_value_not_boolean)),
help(
r#"Update the command to return "true" if execution is required, or "false" if not."#
)
)]
EnsureCheckValueNotBoolean {
sh_cmd: ShCmd,
#[cfg(feature = "error_reporting")]
#[source_code]
sh_cmd_string: String,
stdout: Option<String>,
},
#[error(
r#"Clean check shell command did not return "true" or "false": `{}`"#,
sh_cmd
)]
#[cfg_attr(
feature = "error_reporting",
diagnostic(code(peace_item_spec_sh_cmd::clean_check_value_not_boolean)),
help(
r#"Update the command to return "true" if execution is required, or "false" if not."#
)
)]
CleanCheckValueNotBoolean {
sh_cmd: ShCmd,
#[cfg(feature = "error_reporting")]
#[source_code]
sh_cmd_string: String,
stdout: Option<String>,
},
#[error("A `peace` runtime error occurred.")]
PeaceRtError(
#[cfg_attr(feature = "error_reporting", diagnostic_source)]
#[source]
#[from]
peace::rt_model::Error,
),
}