Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 2s
CI Pipeline / Clippy Lints (push) Failing after 1s
CI Pipeline / Rust Unit Tests (push) Failing after 2s
CI Pipeline / Security Audit (push) Failing after 2s
CI Pipeline / Frontend Lint & Type Check (push) Failing after 3s
CI Pipeline / Build .deb & Release (push) Has been skipped
- health_poller: persist agent_version from HealthData.version - health_poller: call /system/info to update os_family, os_name, arch - enrollment: set os_family and arch from os_details during approval - enrollment: build os_name from os+os_version when name field absent - COALESCE in UPDATE preserves existing values when new data unavailable - version bump 0.1.7 -> 0.1.8
50 lines
1.5 KiB
Rust
Executable File
50 lines
1.5 KiB
Rust
Executable File
//! Error types for the pm-agent-client crate.
|
|
|
|
use thiserror::Error;
|
|
|
|
/// Top-level error type returned by [`crate::client::AgentClient`] methods.
|
|
#[derive(Debug, Error)]
|
|
pub enum AgentClientError {
|
|
/// TLS configuration or handshake failure.
|
|
#[error("TLS error: {0}")]
|
|
Tls(String),
|
|
|
|
/// Unable to establish a TCP/TLS connection to the agent.
|
|
#[error("Connection error: {0}")]
|
|
Connect(#[source] reqwest::Error),
|
|
|
|
/// An HTTP request or response transport error (not a timeout).
|
|
#[error("Request error: {0}")]
|
|
Request(#[source] reqwest::Error),
|
|
|
|
/// The request did not complete within the configured timeout.
|
|
#[error("Request timed out")]
|
|
Timeout,
|
|
|
|
/// The agent returned a non-2xx HTTP status or `success: false` in the
|
|
/// response envelope.
|
|
#[error("Agent API error [{code}]: {message}")]
|
|
ApiError {
|
|
/// Machine-readable error code supplied by the agent (e.g. `"NOT_FOUND"`).
|
|
code: String,
|
|
/// Human-readable description returned by the agent.
|
|
message: String,
|
|
},
|
|
|
|
/// JSON deserialization of the agent response failed.
|
|
#[error("Failed to deserialise agent response: {0}")]
|
|
Deserialize(#[from] serde_json::Error),
|
|
}
|
|
|
|
impl From<reqwest::Error> for AgentClientError {
|
|
fn from(err: reqwest::Error) -> Self {
|
|
if err.is_timeout() {
|
|
AgentClientError::Timeout
|
|
} else if err.is_connect() {
|
|
AgentClientError::Connect(err)
|
|
} else {
|
|
AgentClientError::Request(err)
|
|
}
|
|
}
|
|
}
|