Skip to main content

rustfs_audit/
error.rs

1//  Copyright 2024 RustFS Team
2//
3//  Licensed under the Apache License, Version 2.0 (the "License");
4//  you may not use this file except in compliance with the License.
5//  You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14
15use thiserror::Error;
16
17/// Result type for audit operations
18pub type AuditResult<T> = Result<T, AuditError>;
19
20/// Errors that can occur during audit operations
21#[derive(Error, Debug)]
22pub enum AuditError {
23    #[error("Configuration error: {0}")]
24    Configuration(String, #[source] Option<Box<dyn std::error::Error + Send + Sync>>),
25
26    #[error("config not loaded")]
27    ConfigNotLoaded,
28
29    #[error("Target error: {0}")]
30    Target(#[from] rustfs_targets::TargetError),
31
32    #[error("System not initialized: {0}")]
33    NotInitialized(String),
34
35    #[error("System already initialized")]
36    AlreadyInitialized,
37
38    #[error("Audit system is paused; entry was not accepted")]
39    Paused,
40
41    #[error("Storage not available: {0}")]
42    StorageNotAvailable(String),
43
44    #[error("Failed to save configuration: {0}")]
45    SaveConfig(#[source] Box<dyn std::error::Error + Send + Sync>),
46
47    #[error("Failed to load configuration: {0}")]
48    LoadConfig(#[source] Box<dyn std::error::Error + Send + Sync>),
49
50    #[error("Serialization error: {0}")]
51    Serialization(#[from] serde_json::Error),
52
53    #[error("I/O error: {0}")]
54    Io(#[from] std::io::Error),
55
56    #[error("Join error: {0}")]
57    Join(#[from] tokio::task::JoinError),
58}