objectiveai_sdk/cli/output/error.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4/// A failure or advisory written to stdout. `fatal: true` means the
5/// process is exiting with a non-zero status; `fatal: false` is a
6/// non-blocking warning (e.g. auto-update failed but the requested
7/// command still ran).
8///
9/// `message` is an arbitrary JSON value so producers can emit
10/// structured payloads (e.g. `{"code": ..., "detail": ...}`). Wrap
11/// a plain string as `Value::String(...)` (or use `.into()`) and the
12/// wire bytes stay identical to the old `String`-only shape.
13#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
14#[schemars(rename = "cli.output.Error")]
15pub struct Error {
16 pub level: Level,
17 pub fatal: bool,
18 pub message: serde_json::Value,
19}
20
21/// Severity matching the conventions used by bunyan / pino / `log` crate
22/// JSON encoders. `fatal` is encoded separately on [`Error`].
23#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema)]
24#[serde(rename_all = "lowercase")]
25#[schemars(rename = "cli.output.Level")]
26pub enum Level {
27 Trace,
28 Debug,
29 Info,
30 Warn,
31 Error,
32}