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