pub enum Diagnostic {
Usage(String),
AuthRequired(String),
NotFound(String),
ServerError(String),
Network(String),
Conflict(String),
Io(String),
Internal(String),
NotImplemented(String),
}Expand description
Library error type. Stable enum variants per dsp-cli/ADR-0012.
Clone is derived so that mock test helpers can hand out
Result<_, Diagnostic> values repeatedly without consuming them.
All current variants hold String, which is Clone.
Variants§
Usage(String)
Bad input from the caller — bad flag, missing argument, unparseable id.
AuthRequired(String)
The server demanded auth and none was supplied (or the token was rejected).
NotFound(String)
The named project / data-model / resource-type does not exist.
ServerError(String)
The server responded with a 5xx or an unparseable response.
Also carries a relayed store rejection from dsp vre sparql query:
the triplestore’s own 4xx is not dsp-cli’s failure to classify, so it
is reported here with the store’s status and its (sanitised, capped)
message. Exit category Runtime (1) — see dsp-cli/ADR-0016 / plan 035 D7.
Network(String)
Could not reach the server.
Conflict(String)
A server-side resource is busy or already exists.
Examples: a dump for this project is already in progress or present;
a DELETE was attempted while the dump was still being produced.
Maps to ExitCategory::Runtime (exit code 1).
Io(String)
A local filesystem operation that the user explicitly requested failed.
Example: writing or renaming the dump file the user asked for.
Distinction from Internal: Internal wraps unexpected internal
I/O (renderer writes, plumbing) and is reached via the blanket
From<std::io::Error> impl. Io is for user-visible filesystem work
(e.g. writing the dump output file) and must be constructed explicitly
with a message that includes the target path.
Warning: the dump file-write path must never use bare ? on a
std::io::Error. Bare ? will hit From<io::Error> and mis-classify
the error as Internal instead of Io. Always map explicitly:
.map_err(|e| Diagnostic::Io(format!("…{path}…: {e}"))).
See the scoped helper stream_dump_to_path in the action (Step 8).
Maps to ExitCategory::Runtime (exit code 1).
Internal(String)
Unexpected state in dsp-cli itself; should be reported as a bug.
NotImplemented(String)
Placeholder for work-in-progress dispatch paths during Phase 1.
Implementations§
Source§impl Diagnostic
impl Diagnostic
pub fn not_implemented(msg: impl Into<String>) -> Self
Sourcepub fn exit_category(&self) -> ExitCategory
pub fn exit_category(&self) -> ExitCategory
Maps a diagnostic to its exit category (per dsp-cli/ADR-0012).
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§impl Debug for Diagnostic
impl Debug for Diagnostic
Source§impl Display for Diagnostic
impl Display for Diagnostic
Source§impl Error for Diagnostic
impl Error for Diagnostic
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for Diagnostic
Bridge from std::io::Error so that ? works inside renderer methods
(and any other function returning Result<_, Diagnostic>) without
spelling out .map_err(|e| Diagnostic::Internal(...)) at every call site.
impl From<Error> for Diagnostic
Bridge from std::io::Error so that ? works inside renderer methods
(and any other function returning Result<_, Diagnostic>) without
spelling out .map_err(|e| Diagnostic::Internal(...)) at every call site.