Skip to main content

co_primitives/types/
diagnostic_message.rs

1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (C) 2026 1io BRANDGUARDIAN GmbH
3
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub enum DiagnosticMessage {
8	// Trace(),
9	// Info(),
10	// Warning(),
11	// Error(),
12	Failure(String),
13}
14impl DiagnosticMessage {
15	pub fn to_error(&self) -> Option<anyhow::Error> {
16		match self {
17			DiagnosticMessage::Failure(diagnostic) => Some(anyhow::anyhow!(diagnostic.clone())),
18		}
19	}
20}
21impl From<anyhow::Error> for DiagnosticMessage {
22	fn from(value: anyhow::Error) -> Self {
23		DiagnosticMessage::Failure(format!("{:?}", value))
24	}
25}