citum_server/error.rs
1/*
2SPDX-License-Identifier: MIT OR Apache-2.0
3SPDX-FileCopyrightText: © 2023-2026 Bruce D'Arcus and Citum contributors
4*/
5
6use citum_engine::ProcessorError;
7use std::borrow::Cow;
8use std::io;
9use thiserror::Error;
10
11/// Server-level errors.
12#[derive(Error, Debug)]
13pub enum ServerError {
14 /// The style YAML was found but failed to parse or validate against the schema.
15 #[error("style validation failed: {0}")]
16 StyleValidation(String),
17
18 /// No resolver in the chain could locate the requested style name, path, or URI.
19 #[error("style not found: {0}")]
20 StyleNotFound(String),
21
22 /// The style was found but inheritance or template resolution failed.
23 #[error("style resolution failed: {0}")]
24 StyleResolution(String),
25
26 /// The chain resolver itself failed to initialize or run.
27 #[error("resolver error: {0}")]
28 ResolverError(String),
29
30 /// Bibliography input could not be deserialized or rendered.
31 #[error("bibliography processing failed: {0}")]
32 BibliographyError(String),
33
34 /// Citation input could not be deserialized or rendered.
35 #[error("citation processing failed: {0}")]
36 CitationError(String),
37
38 /// An I/O operation failed while reading input or writing output.
39 #[error("IO error: {0}")]
40 IoError(#[from] io::Error),
41
42 /// JSON input or output failed to deserialize or serialize.
43 #[error("JSON error: {0}")]
44 JsonError(#[from] serde_json::Error),
45
46 /// YAML style parsing failed.
47 #[error("YAML error: {0}")]
48 YamlError(#[from] serde_yaml::Error),
49
50 /// The underlying citation engine returned an error.
51 #[error("engine error: {0}")]
52 EngineError(#[from] ProcessorError),
53
54 /// A required JSON-RPC parameter was missing from the request.
55 #[error("missing required field: {0}")]
56 MissingField(Cow<'static, str>),
57
58 /// The request asked for an unsupported output format.
59 #[error("unsupported output format: {0}")]
60 UnsupportedOutputFormat(Cow<'static, str>),
61}