Skip to main content

wsfed_caep/
error.rs

1// SPDX-FileCopyrightText: 2026 Iya CyberSecurity Solutions, LLC
2// SPDX-License-Identifier: MIT
3
4use std::fmt;
5
6#[derive(Debug, Clone)]
7pub struct WsFedError {
8    pub code: String,
9    pub message: String,
10}
11
12impl WsFedError {
13    pub fn new(code: &str, message: impl Into<String>) -> Self {
14        Self { code: code.to_string(), message: message.into() }
15    }
16}
17
18impl fmt::Display for WsFedError {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        f.write_str(&self.message)
21    }
22}
23
24impl std::error::Error for WsFedError {}
25
26pub fn fail(code: &str, message: impl Into<String>) -> WsFedError {
27    WsFedError::new(code, message)
28}
29
30pub type Result<T> = std::result::Result<T, WsFedError>;